@airgap/icp 0.13.9-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +7 -0
- package/airgap-coinlib-icp.min.js +91766 -0
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +71 -0
- package/readme.md +121 -0
- package/v1/block-explorer/ICPBlockExplorer.d.ts +9 -0
- package/v1/block-explorer/ICPBlockExplorer.js +74 -0
- package/v1/block-explorer/ICPBlockExplorer.js.map +1 -0
- package/v1/index.d.ts +12 -0
- package/v1/index.js +11 -0
- package/v1/index.js.map +1 -0
- package/v1/module/ICPModule.d.ts +15 -0
- package/v1/module/ICPModule.js +107 -0
- package/v1/module/ICPModule.js.map +1 -0
- package/v1/protocol/ICPImplementation.d.ts +26 -0
- package/v1/protocol/ICPImplementation.js +334 -0
- package/v1/protocol/ICPImplementation.js.map +1 -0
- package/v1/protocol/ICPProtocol.d.ts +38 -0
- package/v1/protocol/ICPProtocol.js +414 -0
- package/v1/protocol/ICPProtocol.js.map +1 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +7 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +21 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.d.ts +4 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.js.map +1 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-icp.json +32 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-icp.json +19 -0
- package/v1/serializer/v3/serializer-companion.d.ts +14 -0
- package/v1/serializer/v3/serializer-companion.js +174 -0
- package/v1/serializer/v3/serializer-companion.js.map +1 -0
- package/v1/serializer/v3/validators/transaction-validator.d.ts +10 -0
- package/v1/serializer/v3/validators/transaction-validator.js +100 -0
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
- package/v1/serializer/v3/validators/validators.d.ts +5 -0
- package/v1/serializer/v3/validators/validators.js +106 -0
- package/v1/serializer/v3/validators/validators.js.map +1 -0
- package/v1/types/governance.d.ts +580 -0
- package/v1/types/governance.js +796 -0
- package/v1/types/governance.js.map +1 -0
- package/v1/types/ledger.d.ts +143 -0
- package/v1/types/ledger.js +146 -0
- package/v1/types/ledger.js.map +1 -0
- package/v1/types/management_idl.d.ts +7 -0
- package/v1/types/management_idl.js +72 -0
- package/v1/types/management_idl.js.map +1 -0
- package/v1/types/protocol.d.ts +8 -0
- package/v1/types/protocol.js +3 -0
- package/v1/types/protocol.js.map +1 -0
- package/v1/types/transaction.d.ts +11 -0
- package/v1/types/transaction.js +3 -0
- package/v1/types/transaction.js.map +1 -0
- package/v1/utils/account.d.ts +24 -0
- package/v1/utils/account.js +112 -0
- package/v1/utils/account.js.map +1 -0
- package/v1/utils/actor.d.ts +246 -0
- package/v1/utils/actor.js +458 -0
- package/v1/utils/actor.js.map +1 -0
- package/v1/utils/agent.d.ts +156 -0
- package/v1/utils/agent.js +16 -0
- package/v1/utils/agent.js.map +1 -0
- package/v1/utils/auth.d.ts +110 -0
- package/v1/utils/auth.js +261 -0
- package/v1/utils/auth.js.map +1 -0
- package/v1/utils/bls.d.ts +38 -0
- package/v1/utils/bls.js +204 -0
- package/v1/utils/bls.js.map +1 -0
- package/v1/utils/buffer.d.ts +70 -0
- package/v1/utils/buffer.js +216 -0
- package/v1/utils/buffer.js.map +1 -0
- package/v1/utils/cbor.d.ts +9 -0
- package/v1/utils/cbor.js +178 -0
- package/v1/utils/cbor.js.map +1 -0
- package/v1/utils/certificate.d.ts +74 -0
- package/v1/utils/certificate.js +396 -0
- package/v1/utils/certificate.js.map +1 -0
- package/v1/utils/convert.d.ts +8 -0
- package/v1/utils/convert.js +80 -0
- package/v1/utils/convert.js.map +1 -0
- package/v1/utils/crypto.d.ts +0 -0
- package/v1/utils/crypto.js +104 -0
- package/v1/utils/crypto.js.map +1 -0
- package/v1/utils/der.d.ts +35 -0
- package/v1/utils/der.js +176 -0
- package/v1/utils/der.js.map +1 -0
- package/v1/utils/errors.d.ts +7 -0
- package/v1/utils/errors.js +38 -0
- package/v1/utils/errors.js.map +1 -0
- package/v1/utils/hdkey.d.ts +13 -0
- package/v1/utils/hdkey.js +242 -0
- package/v1/utils/hdkey.js.map +1 -0
- package/v1/utils/http.d.ts +284 -0
- package/v1/utils/http.js +614 -0
- package/v1/utils/http.js.map +1 -0
- package/v1/utils/idl.d.ts +515 -0
- package/v1/utils/idl.js +2103 -0
- package/v1/utils/idl.js.map +1 -0
- package/v1/utils/leb128.d.ts +63 -0
- package/v1/utils/leb128.js +224 -0
- package/v1/utils/leb128.js.map +1 -0
- package/v1/utils/polling.d.ts +59 -0
- package/v1/utils/polling.js +325 -0
- package/v1/utils/polling.js.map +1 -0
- package/v1/utils/principal.d.ts +58 -0
- package/v1/utils/principal.js +543 -0
- package/v1/utils/principal.js.map +1 -0
- package/v1/utils/secp256k1.d.ts +79 -0
- package/v1/utils/secp256k1.js +253 -0
- package/v1/utils/secp256k1.js.map +1 -0
- package/v1/utils/transaction.d.ts +3 -0
- package/v1/utils/transaction.js +56 -0
- package/v1/utils/transaction.js.map +1 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
54
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
55
|
+
if (!m) return o;
|
|
56
|
+
var i = m.call(o), r, ar = [], e;
|
|
57
|
+
try {
|
|
58
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
59
|
+
}
|
|
60
|
+
catch (error) { e = { error: error }; }
|
|
61
|
+
finally {
|
|
62
|
+
try {
|
|
63
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
64
|
+
}
|
|
65
|
+
finally { if (e) throw e.error; }
|
|
66
|
+
}
|
|
67
|
+
return ar;
|
|
68
|
+
};
|
|
69
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
70
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
71
|
+
};
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.Secp256k1KeyIdentity = exports.Secp256k1PublicKey = void 0;
|
|
74
|
+
/* eslint-disable no-underscore-dangle */
|
|
75
|
+
var secp256k1_1 = __importDefault(require("secp256k1"));
|
|
76
|
+
var js_sha256_1 = require("js-sha256");
|
|
77
|
+
var tweetnacl_1 = require("tweetnacl");
|
|
78
|
+
var hdkey_1 = __importDefault(require("./hdkey"));
|
|
79
|
+
var bip39_1 = require("bip39");
|
|
80
|
+
var buffer_1 = require("./buffer");
|
|
81
|
+
var der_1 = require("./der");
|
|
82
|
+
var auth_1 = require("./auth");
|
|
83
|
+
var Secp256k1PublicKey = /** @class */ (function () {
|
|
84
|
+
// `fromRaw` and `fromDer` should be used for instantiation, not this constructor.
|
|
85
|
+
function Secp256k1PublicKey(key) {
|
|
86
|
+
key.byteLength;
|
|
87
|
+
this.rawKey = key;
|
|
88
|
+
this.derKey = Secp256k1PublicKey.derEncode(key);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Construct Secp256k1PublicKey from an existing PublicKey
|
|
92
|
+
* @param {PublicKey} key
|
|
93
|
+
* @returns {Secp256k1PublicKey} Instance of Secp256k1PublicKey
|
|
94
|
+
*/
|
|
95
|
+
Secp256k1PublicKey.from = function (key) {
|
|
96
|
+
return this.fromDer(key.toDer());
|
|
97
|
+
};
|
|
98
|
+
Secp256k1PublicKey.fromRaw = function (rawKey) {
|
|
99
|
+
return new Secp256k1PublicKey(rawKey);
|
|
100
|
+
};
|
|
101
|
+
Secp256k1PublicKey.fromDer = function (derKey) {
|
|
102
|
+
return new Secp256k1PublicKey(this.derDecode(derKey));
|
|
103
|
+
};
|
|
104
|
+
Secp256k1PublicKey.derEncode = function (publicKey) {
|
|
105
|
+
return (0, der_1.wrapDER)(publicKey, der_1.SECP256K1_OID).buffer;
|
|
106
|
+
};
|
|
107
|
+
Secp256k1PublicKey.derDecode = function (key) {
|
|
108
|
+
return (0, der_1.unwrapDER)(key, der_1.SECP256K1_OID);
|
|
109
|
+
};
|
|
110
|
+
Secp256k1PublicKey.prototype.toDer = function () {
|
|
111
|
+
return this.derKey;
|
|
112
|
+
};
|
|
113
|
+
Secp256k1PublicKey.prototype.toRaw = function () {
|
|
114
|
+
return this.rawKey;
|
|
115
|
+
};
|
|
116
|
+
return Secp256k1PublicKey;
|
|
117
|
+
}());
|
|
118
|
+
exports.Secp256k1PublicKey = Secp256k1PublicKey;
|
|
119
|
+
var Secp256k1KeyIdentity = /** @class */ (function (_super) {
|
|
120
|
+
__extends(Secp256k1KeyIdentity, _super);
|
|
121
|
+
function Secp256k1KeyIdentity(publicKey, _privateKey) {
|
|
122
|
+
var _this = _super.call(this) || this;
|
|
123
|
+
_this._privateKey = _privateKey;
|
|
124
|
+
_this._publicKey = publicKey;
|
|
125
|
+
return _this;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Generates an identity. If a seed is provided, the keys are generated from the
|
|
129
|
+
* seed according to BIP 0032. Otherwise, the key pair is randomly generated.
|
|
130
|
+
* This method throws an error in case the seed is not 32 bytes long or invalid
|
|
131
|
+
* for use as a private key.
|
|
132
|
+
* @param {Uint8Array} seed the optional seed
|
|
133
|
+
* @returns {Secp256k1KeyIdentity}
|
|
134
|
+
*/
|
|
135
|
+
Secp256k1KeyIdentity.generate = function (seed) {
|
|
136
|
+
if (seed && seed.byteLength !== 32) {
|
|
137
|
+
throw new Error('Secp256k1 Seed needs to be 32 bytes long.');
|
|
138
|
+
}
|
|
139
|
+
var privateKey;
|
|
140
|
+
if (seed) {
|
|
141
|
+
// private key from seed according to https://en.bitcoin.it/wiki/BIP_0032
|
|
142
|
+
// master key generation:
|
|
143
|
+
privateKey = seed;
|
|
144
|
+
if (!secp256k1_1.default.privateKeyVerify(privateKey)) {
|
|
145
|
+
throw new Error('The seed is invalid.');
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
privateKey = new Uint8Array((0, tweetnacl_1.randomBytes)(32));
|
|
150
|
+
while (!secp256k1_1.default.privateKeyVerify(privateKey)) {
|
|
151
|
+
privateKey = new Uint8Array((0, tweetnacl_1.randomBytes)(32));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
var publicKeyRaw = secp256k1_1.default.publicKeyCreate(privateKey, false);
|
|
155
|
+
var publicKey = Secp256k1PublicKey.fromRaw(publicKeyRaw);
|
|
156
|
+
return new this(publicKey, privateKey);
|
|
157
|
+
};
|
|
158
|
+
Secp256k1KeyIdentity.fromParsedJson = function (obj) {
|
|
159
|
+
var _a = __read(obj, 2), publicKeyRaw = _a[0], privateKeyRaw = _a[1];
|
|
160
|
+
return new Secp256k1KeyIdentity(Secp256k1PublicKey.fromRaw((0, buffer_1.fromHexString)(publicKeyRaw)), (0, buffer_1.fromHexString)(privateKeyRaw));
|
|
161
|
+
};
|
|
162
|
+
Secp256k1KeyIdentity.fromJSON = function (json) {
|
|
163
|
+
var parsed = JSON.parse(json);
|
|
164
|
+
if (Array.isArray(parsed)) {
|
|
165
|
+
if (typeof parsed[0] === 'string' && typeof parsed[1] === 'string') {
|
|
166
|
+
return this.fromParsedJson([parsed[0], parsed[1]]);
|
|
167
|
+
}
|
|
168
|
+
throw new Error('Deserialization error: JSON must have at least 2 items.');
|
|
169
|
+
}
|
|
170
|
+
throw new Error("Deserialization error: Invalid JSON type for string: ".concat(JSON.stringify(json)));
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* generates an identity from a public and private key. Please ensure that you are generating these keys securely and protect the user's private key
|
|
174
|
+
* @param {ArrayBuffer} publicKey
|
|
175
|
+
* @param {ArrayBuffer} privateKey
|
|
176
|
+
* @returns {Secp256k1KeyIdentity}
|
|
177
|
+
*/
|
|
178
|
+
Secp256k1KeyIdentity.fromKeyPair = function (publicKey, privateKey) {
|
|
179
|
+
return new Secp256k1KeyIdentity(Secp256k1PublicKey.fromRaw(publicKey), privateKey);
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* generates an identity from an existing secret key, and is the correct method to generate an identity from a seed phrase. Please ensure you protect the user's private key.
|
|
183
|
+
* @param {ArrayBuffer} secretKey
|
|
184
|
+
* @returns {Secp256k1KeyIdentity}
|
|
185
|
+
*/
|
|
186
|
+
Secp256k1KeyIdentity.fromSecretKey = function (secretKey) {
|
|
187
|
+
var publicKey = secp256k1_1.default.publicKeyCreate(new Uint8Array(secretKey), false);
|
|
188
|
+
var identity = Secp256k1KeyIdentity.fromKeyPair(publicKey, new Uint8Array(secretKey));
|
|
189
|
+
return identity;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Generates an identity from a seed phrase. Use carefully - seed phrases should only be used in secure contexts, and you should avoid having users copying and pasting seed phrases as much as possible.
|
|
193
|
+
* @param {string | string[]} seedPhrase - either an array of words or a string of words separated by spaces.
|
|
194
|
+
* @param password - optional password to be used by bip39
|
|
195
|
+
* @returns Secp256k1KeyIdentity
|
|
196
|
+
*/
|
|
197
|
+
Secp256k1KeyIdentity.fromSeedPhrase = function (seedPhrase, password) {
|
|
198
|
+
// Convert to string for convenience
|
|
199
|
+
var phrase = Array.isArray(seedPhrase) ? seedPhrase.join(' ') : seedPhrase;
|
|
200
|
+
// Warn if provided phrase is not conventional
|
|
201
|
+
if (phrase.split(' ').length < 12 || phrase.split(' ').length > 24) {
|
|
202
|
+
console.warn('Warning - an unusually formatted seed phrase has been provided. Decoding may not work as expected');
|
|
203
|
+
}
|
|
204
|
+
var seed = (0, bip39_1.mnemonicToSeedSync)(phrase, password);
|
|
205
|
+
var root = hdkey_1.default.fromMasterSeed(seed);
|
|
206
|
+
var addrnode = root.derive("m/44'/223'/0'/0/0");
|
|
207
|
+
return Secp256k1KeyIdentity.fromSecretKey(addrnode.privateKey);
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Serialize this key to JSON-serializable object.
|
|
211
|
+
* @returns {JsonableSecp256k1Identity}
|
|
212
|
+
*/
|
|
213
|
+
Secp256k1KeyIdentity.prototype.toJSON = function () {
|
|
214
|
+
return [(0, buffer_1.toHexString)(this._publicKey.toRaw()), (0, buffer_1.toHexString)(this._privateKey)];
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Return a copy of the key pair.
|
|
218
|
+
* @returns {KeyPair}
|
|
219
|
+
*/
|
|
220
|
+
Secp256k1KeyIdentity.prototype.getKeyPair = function () {
|
|
221
|
+
return {
|
|
222
|
+
secretKey: this._privateKey,
|
|
223
|
+
publicKey: this._publicKey
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Return the public key.
|
|
228
|
+
* @returns {Secp256k1PublicKey}
|
|
229
|
+
*/
|
|
230
|
+
Secp256k1KeyIdentity.prototype.getPublicKey = function () {
|
|
231
|
+
return this._publicKey;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Signs a blob of data, with this identity's private key.
|
|
235
|
+
* @param {ArrayBuffer} challenge - challenge to sign with this identity's secretKey, producing a signature
|
|
236
|
+
* @returns {Promise<Signature>} signature
|
|
237
|
+
*/
|
|
238
|
+
Secp256k1KeyIdentity.prototype.sign = function (challenge) {
|
|
239
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
240
|
+
var hash, signature;
|
|
241
|
+
return __generator(this, function (_a) {
|
|
242
|
+
hash = js_sha256_1.sha256.create();
|
|
243
|
+
hash.update(challenge);
|
|
244
|
+
signature = secp256k1_1.default.ecdsaSign(new Uint8Array(hash.digest()), new Uint8Array(this._privateKey)).signature.buffer;
|
|
245
|
+
return [2 /*return*/, signature];
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
return Secp256k1KeyIdentity;
|
|
250
|
+
}(auth_1.SignIdentity));
|
|
251
|
+
exports.Secp256k1KeyIdentity = Secp256k1KeyIdentity;
|
|
252
|
+
exports.default = Secp256k1KeyIdentity;
|
|
253
|
+
//# sourceMappingURL=secp256k1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AS,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAA;gBACvH,sBAAO,SAAsB,EAAA;;;KAC9B;IACH,2BAAC;AAAD,CAAC,AA1ID,CAA0C,mBAAY,GA0IrD;AA1IY,oDAAoB;AA4IjC,kBAAe,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.decodeTx = exports.encodeTx = void 0;
|
|
30
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
31
|
+
var bs58check = __importStar(require("@airgap/coinlib-core/dependencies/src/bs58check-2.1.2/index"));
|
|
32
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
33
|
+
var base64Check_1 = __importDefault(require("@airgap/coinlib-core/utils/base64Check"));
|
|
34
|
+
var TRANSACTION_PREFIX = 'tx_';
|
|
35
|
+
function encodeTx(transaction) {
|
|
36
|
+
return "".concat(TRANSACTION_PREFIX).concat(base64Check_1.default.encode(transaction));
|
|
37
|
+
}
|
|
38
|
+
exports.encodeTx = encodeTx;
|
|
39
|
+
function decodeTx(transaction) {
|
|
40
|
+
var encoded = transaction.replace(TRANSACTION_PREFIX, '');
|
|
41
|
+
try {
|
|
42
|
+
return base64Check_1.default.decode(encoded);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
//
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
return bs58check.decode(encoded);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
//
|
|
52
|
+
}
|
|
53
|
+
throw new errors_1.InvalidValueError(coinlib_core_1.Domain.AETERNITY, 'invalid TX-encoding');
|
|
54
|
+
}
|
|
55
|
+
exports.decodeTx = decodeTx;
|
|
56
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/v1/utils/transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA6C;AAC7C,qGAAwF;AACxF,sDAA+D;AAC/D,uFAA8D;AAE9D,IAAM,kBAAkB,GAAW,KAAK,CAAA;AAExC,SAAgB,QAAQ,CAAC,WAAgB;IACvC,OAAO,UAAG,kBAAkB,SAAG,qBAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAE,CAAA;AAChE,CAAC;AAFD,4BAEC;AAED,SAAgB,QAAQ,CAAC,WAAmB;IAC1C,IAAM,OAAO,GAAW,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAA;IAEnE,IAAI;QACF,OAAO,qBAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;KACjC;IAAC,OAAO,KAAK,EAAE;QACd,EAAE;KACH;IAED,IAAI;QACF,OAAO,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;KACjC;IAAC,OAAO,KAAK,EAAE;QACd,EAAE;KACH;IAED,MAAM,IAAI,0BAAiB,CAAC,qBAAM,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAA;AACtE,CAAC;AAhBD,4BAgBC"}
|