raiden-ts
Version:
Raiden Light Client Typescript/Javascript SDK
72 lines • 3.07 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BalanceProofZero = exports.BalanceProof = exports.Lock = exports.ChannelUniqueKey = exports.ChannelKey = void 0;
const constants_1 = require("@ethersproject/constants");
const t = __importStar(require("io-ts"));
const constants_2 = require("../constants");
const types_1 = require("../utils/types");
exports.ChannelKey = (0, types_1.templateLiteral)(/^0x[0-9a-fA-F]{40}@0x[0-9a-fA-F]{40}$/);
exports.ChannelUniqueKey = (0, types_1.templateLiteral)(/^0x[0-9a-fA-F]{40}@0x[0-9a-fA-F]{40}#\d+$/);
// Represents a HashTime-Locked amount in a channel
exports.Lock = t.intersection([
t.type({
amount: (0, types_1.UInt)(32),
expiration: (0, types_1.UInt)(32),
secrethash: types_1.Hash,
}),
t.partial({ registered: t.literal(true) }),
], 'Lock');
/**
* Balance Proof constructed from an EnvelopeMessage
* Either produced by us or received from the partner, the BPs are generated from the messages
* because BP signature requires the hash of the message, for authentication of data not included
* nor relevant for the smartcontract/BP itself, but so for the peers (e.g. payment_id)
*/
const _BalanceProof = t.readonly(t.type({
// channel data
chainId: (0, types_1.UInt)(32),
tokenNetworkAddress: types_1.Address,
channelId: (0, types_1.UInt)(32),
// balance proof data
nonce: (0, types_1.UInt)(8),
transferredAmount: (0, types_1.UInt)(32),
lockedAmount: (0, types_1.UInt)(32),
locksroot: types_1.Hash,
additionalHash: types_1.Hash,
}));
exports.BalanceProof = _BalanceProof;
exports.BalanceProofZero = {
chainId: constants_1.Zero,
tokenNetworkAddress: constants_1.AddressZero,
channelId: constants_1.Zero,
nonce: constants_1.Zero,
transferredAmount: constants_1.Zero,
lockedAmount: constants_1.Zero,
locksroot: constants_2.LocksrootZero,
additionalHash: constants_1.HashZero,
signature: constants_2.SignatureZero,
};
//# sourceMappingURL=types.js.map