@airgap/icp 0.13.11-beta.1 → 0.13.11-beta.10
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/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +6 -9
- 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 +14 -0
- package/v1/index.js +14 -0
- package/v1/index.js.map +1 -0
- package/v1/module/ICPModule.d.ts +14 -0
- package/v1/module/ICPModule.js +119 -0
- package/v1/module/ICPModule.js.map +1 -0
- package/v1/module.d.ts +3 -0
- package/v1/module.js +24 -0
- package/v1/module.js.map +1 -0
- package/v1/protocol/ICPImplementation.d.ts +34 -0
- package/v1/protocol/ICPImplementation.js +376 -0
- package/v1/protocol/ICPImplementation.js.map +1 -0
- package/v1/protocol/ICPProtocol.d.ts +45 -0
- package/v1/protocol/ICPProtocol.js +423 -0
- package/v1/protocol/ICPProtocol.js.map +1 -0
- package/v1/protocol/icrc/CkBTCProtocol.d.ts +13 -0
- package/v1/protocol/icrc/CkBTCProtocol.js +328 -0
- package/v1/protocol/icrc/CkBTCProtocol.js.map +1 -0
- package/v1/protocol/icrc/ICRC1Protocol.d.ts +95 -0
- package/v1/protocol/icrc/ICRC1Protocol.js +717 -0
- package/v1/protocol/icrc/ICRC1Protocol.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 +190 -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/ckbtc/metadata.d.ts +4 -0
- package/v1/types/ckbtc/metadata.js +3 -0
- package/v1/types/ckbtc/metadata.js.map +1 -0
- package/v1/types/crypto.d.ts +2 -0
- package/v1/types/crypto.js +3 -0
- package/v1/types/crypto.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/icrc/account.d.ts +4 -0
- package/v1/types/icrc/account.js +3 -0
- package/v1/types/icrc/account.js.map +1 -0
- package/v1/types/icrc/ledger.d.ts +15 -0
- package/v1/types/icrc/ledger.js +92 -0
- package/v1/types/icrc/ledger.js.map +1 -0
- package/v1/types/icrc/metadata.d.ts +6 -0
- package/v1/types/icrc/metadata.js +3 -0
- package/v1/types/icrc/metadata.js.map +1 -0
- package/v1/types/icrc/transfer.d.ts +9 -0
- package/v1/types/icrc/transfer.js +3 -0
- package/v1/types/icrc/transfer.js.map +1 -0
- package/v1/types/ledger.d.ts +142 -0
- package/v1/types/ledger.js +145 -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 +37 -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 +10 -0
- package/v1/utils/convert.js +88 -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 +265 -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/icrc1.d.ts +20 -0
- package/v1/utils/icrc1.js +171 -0
- package/v1/utils/icrc1.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 +278 -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,328 @@
|
|
|
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 __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
44
|
+
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;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.createCkBTCOnlineProtocolOptions = exports.createCkBTCOfflineProtocolOptions = exports.CKBTC_MAINNET_PROTOCOL_NETWORK = exports.createCkBTCOnlineProtocol = exports.createCkBTCOfflineProtocol = void 0;
|
|
66
|
+
// tslint:disable: max-classes-per-file
|
|
67
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
68
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
69
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
70
|
+
var auth_1 = require("../../utils/auth");
|
|
71
|
+
var icrc1_1 = require("../../utils/icrc1");
|
|
72
|
+
var ICPImplementation_1 = require("../ICPImplementation");
|
|
73
|
+
var ICRC1Protocol_1 = require("./ICRC1Protocol");
|
|
74
|
+
// Implementation
|
|
75
|
+
var CKBTC_METADATA = {
|
|
76
|
+
identifier: coinlib_core_1.SubProtocolSymbols.ICP_CKBTC,
|
|
77
|
+
name: 'ckBTC',
|
|
78
|
+
units: {
|
|
79
|
+
ckBTC: {
|
|
80
|
+
symbol: { value: 'ckBTC' },
|
|
81
|
+
decimals: 8
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
mainUnit: 'ckBTC',
|
|
85
|
+
feeDefaults: {
|
|
86
|
+
low: (0, module_kit_1.newAmount)(10, 'blockchain'),
|
|
87
|
+
medium: (0, module_kit_1.newAmount)(10, 'blockchain'),
|
|
88
|
+
high: (0, module_kit_1.newAmount)(10, 'blockchain')
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var CkBTCOfflineProtocolImpl = /** @class */ (function (_super) {
|
|
92
|
+
__extends(CkBTCOfflineProtocolImpl, _super);
|
|
93
|
+
function CkBTCOfflineProtocolImpl(options) {
|
|
94
|
+
var completeOptions = createCkBTCOfflineProtocolOptions(options.ledgerCanisterId);
|
|
95
|
+
return _super.call(this, __assign(__assign({}, completeOptions), CKBTC_METADATA)) || this;
|
|
96
|
+
}
|
|
97
|
+
return CkBTCOfflineProtocolImpl;
|
|
98
|
+
}(ICRC1Protocol_1.ICRC1OfflineProtocolImpl));
|
|
99
|
+
var CkBTCOnlineProtocolImpl = /** @class */ (function (_super) {
|
|
100
|
+
__extends(CkBTCOnlineProtocolImpl, _super);
|
|
101
|
+
function CkBTCOnlineProtocolImpl(options) {
|
|
102
|
+
var completeOptions = createCkBTCOnlineProtocolOptions(options.network);
|
|
103
|
+
return _super.call(this, __assign(__assign({}, completeOptions), CKBTC_METADATA)) || this;
|
|
104
|
+
}
|
|
105
|
+
CkBTCOnlineProtocolImpl.prototype.getTransactionsForPublicKey = function (publicKey, limit, cursor) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
+
var address;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
switch (_a.label) {
|
|
110
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
111
|
+
case 1:
|
|
112
|
+
address = _a.sent();
|
|
113
|
+
return [2 /*return*/, this.getTransactionsForAddress(address, limit, cursor)];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
CkBTCOnlineProtocolImpl.prototype.getTransactionsForAddress = function (address, limit, cursor) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
+
var actor, account, defaultFee, getTransactionsResult, okResult, transactions, last, airGapTransactions, next, hasNext;
|
|
121
|
+
var _this = this;
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
switch (_a.label) {
|
|
124
|
+
case 0:
|
|
125
|
+
actor = this.createIndexerActor();
|
|
126
|
+
account = (0, icrc1_1.getICRC1AccountFromAddress)(address);
|
|
127
|
+
return [4 /*yield*/, this.fee()];
|
|
128
|
+
case 1:
|
|
129
|
+
defaultFee = _a.sent();
|
|
130
|
+
return [4 /*yield*/, actor.get_account_transactions({
|
|
131
|
+
account: (0, icrc1_1.encodeICRC1Account)(account),
|
|
132
|
+
start: (cursor === null || cursor === void 0 ? void 0 : cursor.next) ? [BigInt(cursor.next)] : [],
|
|
133
|
+
max_results: BigInt(limit + 1)
|
|
134
|
+
})];
|
|
135
|
+
case 2:
|
|
136
|
+
getTransactionsResult = _a.sent();
|
|
137
|
+
if (getTransactionsResult.Err) {
|
|
138
|
+
throw new errors_1.OperationFailedError(coinlib_core_1.Domain.ICP, "ICRC1 get transactions failed (".concat(getTransactionsResult.Err.message, ")"));
|
|
139
|
+
}
|
|
140
|
+
okResult = getTransactionsResult.Ok;
|
|
141
|
+
transactions = okResult.transactions;
|
|
142
|
+
last = okResult.oldest_tx_id && okResult.oldest_tx_id.length > 0 ? okResult.oldest_tx_id[0].toString() : undefined;
|
|
143
|
+
airGapTransactions = transactions
|
|
144
|
+
.map(function (transactionWithId) {
|
|
145
|
+
var transaction = transactionWithId.transaction;
|
|
146
|
+
if (transaction.kind === 'transfer' && transaction.transfer[0]) {
|
|
147
|
+
var transfer = transaction.transfer[0];
|
|
148
|
+
var from = (0, ICPImplementation_1.getAddressFromPrincipal)(transfer.from.owner, transfer.from.subaccount);
|
|
149
|
+
var to = (0, ICPImplementation_1.getAddressFromPrincipal)(transfer.to.owner, transfer.to.subaccount);
|
|
150
|
+
return {
|
|
151
|
+
from: [from],
|
|
152
|
+
to: [to],
|
|
153
|
+
isInbound: to === address,
|
|
154
|
+
amount: (0, module_kit_1.newAmount)(transfer.amount.toString(), 'blockchain'),
|
|
155
|
+
fee: transfer.fee && transfer.fee[0]
|
|
156
|
+
? (0, module_kit_1.newAmount)(transfer.fee[0].toString(), 'blockchain')
|
|
157
|
+
: (0, module_kit_1.newAmount)(defaultFee, 'blockchain'),
|
|
158
|
+
network: _this.options.network,
|
|
159
|
+
status: {
|
|
160
|
+
type: 'applied'
|
|
161
|
+
},
|
|
162
|
+
timestamp: Number(transaction.timestamp),
|
|
163
|
+
arbitraryData: transfer.memo && transfer.memo[0] ? Buffer.from(transfer.memo[0]).toString('hex') : undefined
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
else if (transaction.kind === 'burn' && transaction.burn[0]) {
|
|
167
|
+
var burn = transaction.burn[0];
|
|
168
|
+
return {
|
|
169
|
+
from: [(0, ICPImplementation_1.getAddressFromPrincipal)(burn.from.owner, burn.from.subaccount)],
|
|
170
|
+
to: ['Burn'],
|
|
171
|
+
isInbound: false,
|
|
172
|
+
amount: (0, module_kit_1.newAmount)(burn.amount.toString(), 'blockchain'),
|
|
173
|
+
fee: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
174
|
+
type: 'burn',
|
|
175
|
+
network: _this.options.network,
|
|
176
|
+
status: {
|
|
177
|
+
type: 'applied'
|
|
178
|
+
},
|
|
179
|
+
timestamp: Number(transaction.timestamp),
|
|
180
|
+
arbitraryData: burn.memo && burn.memo[0] ? Buffer.from(burn.memo[0]).toString('hex') : undefined
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
else if (transaction.kind === 'mint' && transaction.mint[0]) {
|
|
184
|
+
var mint = transaction.mint[0];
|
|
185
|
+
return {
|
|
186
|
+
from: ['Mint'],
|
|
187
|
+
to: [(0, ICPImplementation_1.getAddressFromPrincipal)(mint.to.owner, mint.to.subaccount)],
|
|
188
|
+
isInbound: false,
|
|
189
|
+
amount: (0, module_kit_1.newAmount)(mint.amount.toString(), 'blockchain'),
|
|
190
|
+
fee: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
191
|
+
type: 'mint',
|
|
192
|
+
network: _this.options.network,
|
|
193
|
+
status: {
|
|
194
|
+
type: 'applied'
|
|
195
|
+
},
|
|
196
|
+
timestamp: Number(transaction.timestamp),
|
|
197
|
+
arbitraryData: mint.memo && mint.memo[0] ? Buffer.from(mint.memo[0]).toString('hex') : undefined
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
return undefined;
|
|
201
|
+
})
|
|
202
|
+
.filter(function (tx) { return tx !== undefined; });
|
|
203
|
+
next = transactions.length > 0 ? transactions.slice(-1)[0].id.toString() : '';
|
|
204
|
+
hasNext = airGapTransactions.length > limit || next !== last;
|
|
205
|
+
return [2 /*return*/, {
|
|
206
|
+
transactions: airGapTransactions.length <= limit ? airGapTransactions : airGapTransactions.slice(0, -1),
|
|
207
|
+
cursor: {
|
|
208
|
+
hasNext: hasNext,
|
|
209
|
+
next: next
|
|
210
|
+
}
|
|
211
|
+
}];
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
CkBTCOnlineProtocolImpl.prototype.metadata = function () {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
+
var baseMetadata, symbol, name, decimals, fee;
|
|
219
|
+
return __generator(this, function (_a) {
|
|
220
|
+
switch (_a.label) {
|
|
221
|
+
case 0: return [4 /*yield*/, this.baseMetadata()];
|
|
222
|
+
case 1:
|
|
223
|
+
baseMetadata = _a.sent();
|
|
224
|
+
symbol = baseMetadata.symbol, name = baseMetadata.name, decimals = baseMetadata.decimals, fee = baseMetadata.fee;
|
|
225
|
+
return [2 /*return*/, {
|
|
226
|
+
symbol: symbol,
|
|
227
|
+
name: name,
|
|
228
|
+
decimals: decimals,
|
|
229
|
+
fee: fee,
|
|
230
|
+
logo: baseMetadata['icrc1:logo'].Text
|
|
231
|
+
}];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
// Custom
|
|
237
|
+
CkBTCOnlineProtocolImpl.prototype.createIndexerActor = function (identity) {
|
|
238
|
+
if (identity === void 0) { identity = new auth_1.AnonymousIdentity(); }
|
|
239
|
+
return this.createActor(this.options.network.indexerCanisterId, function (_a) {
|
|
240
|
+
var IDL = _a.IDL;
|
|
241
|
+
var TxId = IDL.Nat;
|
|
242
|
+
var Account = IDL.Record({
|
|
243
|
+
owner: IDL.Principal,
|
|
244
|
+
subaccount: IDL.Opt(IDL.Vec(IDL.Nat8))
|
|
245
|
+
});
|
|
246
|
+
var GetAccountTransactionsArgs = IDL.Record({
|
|
247
|
+
max_results: IDL.Nat,
|
|
248
|
+
start: IDL.Opt(TxId),
|
|
249
|
+
account: Account
|
|
250
|
+
});
|
|
251
|
+
var Transaction = IDL.Record({
|
|
252
|
+
burn: IDL.Opt(IDL.Record({
|
|
253
|
+
from: Account,
|
|
254
|
+
memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
255
|
+
created_at_time: IDL.Opt(IDL.Nat64),
|
|
256
|
+
amount: IDL.Nat
|
|
257
|
+
})),
|
|
258
|
+
kind: IDL.Text,
|
|
259
|
+
mint: IDL.Opt(IDL.Record({
|
|
260
|
+
to: Account,
|
|
261
|
+
memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
262
|
+
created_at_time: IDL.Opt(IDL.Nat64),
|
|
263
|
+
amount: IDL.Nat
|
|
264
|
+
})),
|
|
265
|
+
timestamp: IDL.Nat64,
|
|
266
|
+
transfer: IDL.Opt(IDL.Record({
|
|
267
|
+
to: Account,
|
|
268
|
+
fee: IDL.Opt(IDL.Nat),
|
|
269
|
+
from: Account,
|
|
270
|
+
memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
271
|
+
created_at_time: IDL.Opt(IDL.Nat64),
|
|
272
|
+
amount: IDL.Nat
|
|
273
|
+
}))
|
|
274
|
+
});
|
|
275
|
+
var TransactionWithId = IDL.Record({
|
|
276
|
+
id: TxId,
|
|
277
|
+
transaction: Transaction
|
|
278
|
+
});
|
|
279
|
+
var GetTransactions = IDL.Record({
|
|
280
|
+
transactions: IDL.Vec(TransactionWithId),
|
|
281
|
+
oldest_tx_id: IDL.Opt(TxId)
|
|
282
|
+
});
|
|
283
|
+
var GetTransactionsErr = IDL.Record({ message: IDL.Text });
|
|
284
|
+
var GetTransactionsResult = IDL.Variant({
|
|
285
|
+
Ok: GetTransactions,
|
|
286
|
+
Err: GetTransactionsErr
|
|
287
|
+
});
|
|
288
|
+
return IDL.Service({
|
|
289
|
+
get_account_transactions: IDL.Func([GetAccountTransactionsArgs], [GetTransactionsResult], [])
|
|
290
|
+
});
|
|
291
|
+
}, identity);
|
|
292
|
+
};
|
|
293
|
+
return CkBTCOnlineProtocolImpl;
|
|
294
|
+
}(ICRC1Protocol_1.ICRC1OnlineProtocolImpl));
|
|
295
|
+
// Factory
|
|
296
|
+
function createCkBTCOfflineProtocol(options) {
|
|
297
|
+
if (options === void 0) { options = {}; }
|
|
298
|
+
return new CkBTCOfflineProtocolImpl(options);
|
|
299
|
+
}
|
|
300
|
+
exports.createCkBTCOfflineProtocol = createCkBTCOfflineProtocol;
|
|
301
|
+
function createCkBTCOnlineProtocol(options) {
|
|
302
|
+
if (options === void 0) { options = {}; }
|
|
303
|
+
return new CkBTCOnlineProtocolImpl(options);
|
|
304
|
+
}
|
|
305
|
+
exports.createCkBTCOnlineProtocol = createCkBTCOnlineProtocol;
|
|
306
|
+
exports.CKBTC_MAINNET_PROTOCOL_NETWORK = {
|
|
307
|
+
name: 'Mainnet',
|
|
308
|
+
type: 'mainnet',
|
|
309
|
+
rpcUrl: 'https://boundary.ic0.app/',
|
|
310
|
+
ledgerCanisterId: 'mxzaz-hqaaa-aaaar-qaada-cai',
|
|
311
|
+
indexerCanisterId: 'n5wcd-faaaa-aaaar-qaaea-cai',
|
|
312
|
+
explorerUrl: 'https://ledger-api.internetcomputer.org'
|
|
313
|
+
};
|
|
314
|
+
var DEFAULT_CKBTC_PROTOCOL_NETWORK = exports.CKBTC_MAINNET_PROTOCOL_NETWORK;
|
|
315
|
+
function createCkBTCOfflineProtocolOptions(ledgerCanisterId) {
|
|
316
|
+
return {
|
|
317
|
+
ledgerCanisterId: ledgerCanisterId !== null && ledgerCanisterId !== void 0 ? ledgerCanisterId : DEFAULT_CKBTC_PROTOCOL_NETWORK.ledgerCanisterId
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
exports.createCkBTCOfflineProtocolOptions = createCkBTCOfflineProtocolOptions;
|
|
321
|
+
function createCkBTCOnlineProtocolOptions(network) {
|
|
322
|
+
if (network === void 0) { network = {}; }
|
|
323
|
+
return {
|
|
324
|
+
network: __assign(__assign({}, DEFAULT_CKBTC_PROTOCOL_NETWORK), network)
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
exports.createCkBTCOnlineProtocolOptions = createCkBTCOnlineProtocolOptions;
|
|
328
|
+
//# sourceMappingURL=CkBTCProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CkBTCProtocol.js","sourceRoot":"","sources":["../../../../src/v1/protocol/icrc/CkBTCProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,qDAAiE;AACjE,sDAAkE;AAClE,iDAQ2B;AAQ3B,yCAA8D;AAC9D,2CAAkF;AAClF,0DAA8D;AAE9D,iDAA8H;AAO9H,iBAAiB;AAEjB,IAAM,cAAc,GAMhB;IACF,UAAU,EAAE,iCAAkB,CA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|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Address, AirGapOfflineProtocol, AirGapOnlineProtocol, AirGapTransaction, AirGapTransactionsWithCursor, Amount, Balance, CryptoDerivative, KeyPair, ProtocolMetadata, PublicKey, SecretKey, TransactionConfiguration, TransactionDetails } from '@airgap/module-kit';
|
|
2
|
+
import { ICPCryptoConfiguration } from '../../types/crypto';
|
|
3
|
+
import { ICRC1Account } from '../../types/icrc/account';
|
|
4
|
+
import { ICRC1Metadata } from '../../types/icrc/metadata';
|
|
5
|
+
import { ICRC1TransferArgs } from '../../types/icrc/transfer';
|
|
6
|
+
import { ICRC1OfflineProtocolOptions, ICRC1OnlineProtocolOptions, ICRC1ProtocolNetwork } from '../../types/protocol';
|
|
7
|
+
import { ICPSignedTransaction, ICPTransactionCursor, ICPUnsignedTransaction } from '../../types/transaction';
|
|
8
|
+
import { ActorSubclass } from '../../utils/actor';
|
|
9
|
+
import { Identity } from '../../utils/auth';
|
|
10
|
+
import * as IDL from '../../utils/idl';
|
|
11
|
+
import { ICPProtocol } from '../ICPProtocol';
|
|
12
|
+
export interface ICRC1OfflineProtocol<_Units extends string = string> extends AirGapOfflineProtocol<{
|
|
13
|
+
AddressResult: Address;
|
|
14
|
+
CryptoConfiguration: ICPCryptoConfiguration;
|
|
15
|
+
Units: _Units;
|
|
16
|
+
SignedTransaction: ICPSignedTransaction;
|
|
17
|
+
UnsignedTransaction: ICPUnsignedTransaction;
|
|
18
|
+
}, 'SubProtocol'> {
|
|
19
|
+
}
|
|
20
|
+
export interface ICRC1OnlineProtocol<_Units extends string = string, _ICRC1Metadata extends ICRC1Metadata = ICRC1Metadata, _ProtocolNetwork extends ICRC1ProtocolNetwork = ICRC1ProtocolNetwork> extends AirGapOnlineProtocol<{
|
|
21
|
+
AddressResult: Address;
|
|
22
|
+
ProtocolNetwork: _ProtocolNetwork;
|
|
23
|
+
Units: _Units;
|
|
24
|
+
FeeEstimation: Amount<_Units>;
|
|
25
|
+
SignedTransaction: ICPSignedTransaction;
|
|
26
|
+
UnsignedTransaction: ICPUnsignedTransaction;
|
|
27
|
+
TransactionCursor: ICPTransactionCursor;
|
|
28
|
+
}, 'SubProtocol', 'FetchDataForAddress'> {
|
|
29
|
+
name(): Promise<string>;
|
|
30
|
+
symbol(): Promise<string>;
|
|
31
|
+
decimals(): Promise<number>;
|
|
32
|
+
fee(): Promise<string>;
|
|
33
|
+
metadata(): Promise<_ICRC1Metadata>;
|
|
34
|
+
totalSupply(): Promise<string>;
|
|
35
|
+
mintingAccount(): Promise<ICRC1Account | undefined>;
|
|
36
|
+
balanceOf(account: ICRC1Account): Promise<string>;
|
|
37
|
+
transfer(privateKey: string, args: ICRC1TransferArgs): Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
export declare abstract class ICRC1OfflineProtocolImpl<_Units extends string = string> implements ICRC1OfflineProtocol<_Units> {
|
|
40
|
+
private readonly options;
|
|
41
|
+
private readonly commonImpl;
|
|
42
|
+
protected readonly icp: ICPProtocol;
|
|
43
|
+
protected constructor(options: ICRC1OfflineProtocolOptions<_Units>);
|
|
44
|
+
getType(): Promise<'token'>;
|
|
45
|
+
mainProtocol(): Promise<string>;
|
|
46
|
+
private readonly metadata;
|
|
47
|
+
getMetadata(): Promise<ProtocolMetadata<_Units>>;
|
|
48
|
+
getAddressFromPublicKey(publicKey: PublicKey): Promise<string>;
|
|
49
|
+
getDetailsFromTransaction(transaction: ICPSignedTransaction | ICPUnsignedTransaction, publicKey: PublicKey): Promise<AirGapTransaction<_Units>[]>;
|
|
50
|
+
getCryptoConfiguration(): Promise<ICPCryptoConfiguration>;
|
|
51
|
+
getKeyPairFromDerivative(derivative: CryptoDerivative): Promise<KeyPair>;
|
|
52
|
+
signTransactionWithSecretKey(transaction: ICPUnsignedTransaction, secretKey: SecretKey): Promise<ICPSignedTransaction>;
|
|
53
|
+
}
|
|
54
|
+
export declare abstract class ICRC1OnlineProtocolImpl<_Units extends string = string, _ICRC1Metadata extends ICRC1Metadata = ICRC1Metadata, _ProtocolNetwork extends ICRC1ProtocolNetwork = ICRC1ProtocolNetwork> implements ICRC1OnlineProtocol<_Units, _ICRC1Metadata, _ProtocolNetwork> {
|
|
55
|
+
protected readonly options: ICRC1OnlineProtocolOptions<_ProtocolNetwork, _Units>;
|
|
56
|
+
private readonly commonImpl;
|
|
57
|
+
protected readonly icp: ICPProtocol;
|
|
58
|
+
protected constructor(options: ICRC1OnlineProtocolOptions<_ProtocolNetwork, _Units>);
|
|
59
|
+
getType(): Promise<'token'>;
|
|
60
|
+
mainProtocol(): Promise<string>;
|
|
61
|
+
private _metadata;
|
|
62
|
+
getMetadata(): Promise<ProtocolMetadata<_Units>>;
|
|
63
|
+
private getPartialMetadata;
|
|
64
|
+
getAddressFromPublicKey(publicKey: PublicKey): Promise<string>;
|
|
65
|
+
getDetailsFromTransaction(transaction: ICPSignedTransaction | ICPUnsignedTransaction, publicKey: PublicKey): Promise<AirGapTransaction<_Units>[]>;
|
|
66
|
+
getNetwork(): Promise<_ProtocolNetwork>;
|
|
67
|
+
abstract getTransactionsForPublicKey(publicKey: PublicKey, limit: number, cursor?: ICPTransactionCursor): Promise<AirGapTransactionsWithCursor<ICPTransactionCursor, _Units>>;
|
|
68
|
+
abstract getTransactionsForAddress(address: string, limit: number, cursor?: ICPTransactionCursor): Promise<AirGapTransactionsWithCursor<ICPTransactionCursor, _Units>>;
|
|
69
|
+
getBalanceOfPublicKey(publicKey: PublicKey): Promise<Balance<_Units>>;
|
|
70
|
+
getBalanceOfAddress(address: string): Promise<Balance<_Units>>;
|
|
71
|
+
private getBalanceOfAccount;
|
|
72
|
+
getTransactionMaxAmountWithPublicKey(publicKey: PublicKey, to: string[], configuration?: TransactionConfiguration<_Units>): Promise<Amount<_Units>>;
|
|
73
|
+
getTransactionFeeWithPublicKey(publicKey: PublicKey, details: TransactionDetails<_Units>[]): Promise<Amount<_Units>>;
|
|
74
|
+
prepareTransactionWithPublicKey(publicKey: PublicKey, details: TransactionDetails<_Units>[], configuration?: TransactionConfiguration<_Units>): Promise<ICPUnsignedTransaction>;
|
|
75
|
+
broadcastTransaction(transaction: ICPSignedTransaction): Promise<string>;
|
|
76
|
+
private _name;
|
|
77
|
+
name(): Promise<string>;
|
|
78
|
+
private _symbol;
|
|
79
|
+
symbol(): Promise<string>;
|
|
80
|
+
private _decimals;
|
|
81
|
+
decimals(): Promise<number>;
|
|
82
|
+
private _fee;
|
|
83
|
+
fee(): Promise<string>;
|
|
84
|
+
abstract metadata(): Promise<_ICRC1Metadata>;
|
|
85
|
+
private _baseMetadata;
|
|
86
|
+
protected baseMetadata(): Promise<ICRC1Metadata & Record<string, any>>;
|
|
87
|
+
private _totalSupply;
|
|
88
|
+
totalSupply(): Promise<string>;
|
|
89
|
+
private _mintingAccount;
|
|
90
|
+
mintingAccount(): Promise<ICRC1Account | undefined>;
|
|
91
|
+
balanceOf(account: ICRC1Account): Promise<string>;
|
|
92
|
+
transfer(privateKey: string, args: ICRC1TransferArgs): Promise<string>;
|
|
93
|
+
protected createLedgerActor(idlFactory?: IDL.InterfaceFactory, identity?: Identity): ActorSubclass;
|
|
94
|
+
protected createActor(canisterId: string, idlFactory?: IDL.InterfaceFactory, identity?: Identity): ActorSubclass;
|
|
95
|
+
}
|