@airgap/icp 0.13.11-beta.5 → 0.13.11-beta.6
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/package.json +3 -2
- package/v1/index.d.ts +3 -2
- package/v1/index.js +4 -1
- package/v1/index.js.map +1 -1
- package/v1/module/ICPModule.d.ts +2 -3
- package/v1/module/ICPModule.js +22 -10
- package/v1/module/ICPModule.js.map +1 -1
- package/v1/protocol/ICPImplementation.d.ts +12 -4
- package/v1/protocol/ICPImplementation.js +87 -55
- package/v1/protocol/ICPImplementation.js.map +1 -1
- package/v1/protocol/ICPProtocol.d.ts +4 -1
- package/v1/protocol/ICPProtocol.js +24 -17
- package/v1/protocol/ICPProtocol.js.map +1 -1
- package/v1/protocol/icrc/CkBTCProtocol.d.ts +16 -0
- package/v1/protocol/icrc/CkBTCProtocol.js +367 -0
- package/v1/protocol/icrc/CkBTCProtocol.js.map +1 -0
- package/v1/protocol/icrc/ICRC1Protocol.d.ts +91 -0
- package/v1/protocol/icrc/ICRC1Protocol.js +699 -0
- package/v1/protocol/icrc/ICRC1Protocol.js.map +1 -0
- package/v1/serializer/v3/serializer-companion.js +16 -0
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- 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/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 +0 -1
- package/v1/types/ledger.js +1 -2
- package/v1/types/ledger.js.map +1 -1
- package/v1/types/protocol.d.ts +21 -1
- package/v1/utils/convert.d.ts +3 -1
- package/v1/utils/convert.js +12 -1
- package/v1/utils/convert.js.map +1 -1
- package/v1/utils/icrc1.d.ts +20 -0
- package/v1/utils/icrc1.js +171 -0
- package/v1/utils/icrc1.js.map +1 -0
|
@@ -0,0 +1,367 @@
|
|
|
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
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
65
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
66
|
+
if (!m) return o;
|
|
67
|
+
var i = m.call(o), r, ar = [], e;
|
|
68
|
+
try {
|
|
69
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
70
|
+
}
|
|
71
|
+
catch (error) { e = { error: error }; }
|
|
72
|
+
finally {
|
|
73
|
+
try {
|
|
74
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
75
|
+
}
|
|
76
|
+
finally { if (e) throw e.error; }
|
|
77
|
+
}
|
|
78
|
+
return ar;
|
|
79
|
+
};
|
|
80
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
81
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
82
|
+
};
|
|
83
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
84
|
+
exports.createCkBTCOnlineProtocolOptions = exports.createCkBTCOfflineProtocolOptions = exports.CKBTC_MAINNET_PROTOCOL_NETWORK = exports.createCkBTCOnlineProtocol = exports.createCkBTCOfflineProtocol = void 0;
|
|
85
|
+
// tslint:disable: max-classes-per-file
|
|
86
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
87
|
+
var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
88
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
89
|
+
var icrc1_1 = require("../../utils/icrc1");
|
|
90
|
+
var ICPImplementation_1 = require("../ICPImplementation");
|
|
91
|
+
var ICRC1Protocol_1 = require("./ICRC1Protocol");
|
|
92
|
+
// Implementation
|
|
93
|
+
var CKBTC_METADATA = {
|
|
94
|
+
identifier: coinlib_core_1.SubProtocolSymbols.ICP_CKBTC,
|
|
95
|
+
name: 'ckBTC',
|
|
96
|
+
units: {
|
|
97
|
+
ckBTC: {
|
|
98
|
+
symbol: { value: 'ckBTC' },
|
|
99
|
+
decimals: 8
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
mainUnit: 'ckBTC',
|
|
103
|
+
feeDefaults: {
|
|
104
|
+
low: (0, module_kit_1.newAmount)(10, 'blockchain'),
|
|
105
|
+
medium: (0, module_kit_1.newAmount)(10, 'blockchain'),
|
|
106
|
+
high: (0, module_kit_1.newAmount)(10, 'blockchain')
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var CkBTCOfflineProtocolImpl = /** @class */ (function (_super) {
|
|
110
|
+
__extends(CkBTCOfflineProtocolImpl, _super);
|
|
111
|
+
function CkBTCOfflineProtocolImpl(options) {
|
|
112
|
+
var completeOptions = createCkBTCOfflineProtocolOptions(options.canisterId);
|
|
113
|
+
return _super.call(this, __assign(__assign({}, completeOptions), CKBTC_METADATA)) || this;
|
|
114
|
+
}
|
|
115
|
+
return CkBTCOfflineProtocolImpl;
|
|
116
|
+
}(ICRC1Protocol_1.ICRC1OfflineProtocolImpl));
|
|
117
|
+
var CkBTCOnlineProtocolImpl = /** @class */ (function (_super) {
|
|
118
|
+
__extends(CkBTCOnlineProtocolImpl, _super);
|
|
119
|
+
function CkBTCOnlineProtocolImpl(options) {
|
|
120
|
+
var completeOptions = createCkBTCOnlineProtocolOptions(options.network);
|
|
121
|
+
return _super.call(this, __assign(__assign({}, completeOptions), CKBTC_METADATA)) || this;
|
|
122
|
+
}
|
|
123
|
+
CkBTCOnlineProtocolImpl.prototype.getTransactionsForPublicKey = function (publicKey, limit, cursor) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
+
var actor, start, empty, transactions, next, hasNext, _loop_1, this_1;
|
|
126
|
+
var _this = this;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0:
|
|
130
|
+
actor = this.createActor(function (_a) {
|
|
131
|
+
var IDL = _a.IDL;
|
|
132
|
+
var GetTransactionsRequest = IDL.Record({
|
|
133
|
+
start: IDL.Nat,
|
|
134
|
+
length: IDL.Nat
|
|
135
|
+
});
|
|
136
|
+
var Account = IDL.Record({
|
|
137
|
+
owner: IDL.Principal,
|
|
138
|
+
subaccount: IDL.Opt(IDL.Vec(IDL.Nat8))
|
|
139
|
+
});
|
|
140
|
+
var Burn = IDL.Record({
|
|
141
|
+
from: Account,
|
|
142
|
+
memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
143
|
+
created_at_time: IDL.Opt(IDL.Nat64),
|
|
144
|
+
amount: IDL.Nat
|
|
145
|
+
});
|
|
146
|
+
var Mint = IDL.Record({
|
|
147
|
+
to: Account,
|
|
148
|
+
memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
149
|
+
created_at_time: IDL.Opt(IDL.Nat64),
|
|
150
|
+
amount: IDL.Nat
|
|
151
|
+
});
|
|
152
|
+
var Transfer = IDL.Record({
|
|
153
|
+
to: Account,
|
|
154
|
+
fee: IDL.Opt(IDL.Nat),
|
|
155
|
+
from: Account,
|
|
156
|
+
memo: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
157
|
+
created_at_time: IDL.Opt(IDL.Nat64),
|
|
158
|
+
amount: IDL.Nat
|
|
159
|
+
});
|
|
160
|
+
var Transaction = IDL.Record({
|
|
161
|
+
burn: IDL.Opt(Burn),
|
|
162
|
+
kind: IDL.Text,
|
|
163
|
+
mint: IDL.Opt(Mint),
|
|
164
|
+
timestamp: IDL.Nat64,
|
|
165
|
+
transfer: IDL.Opt(Transfer)
|
|
166
|
+
});
|
|
167
|
+
var ArchivedTransactionRange = IDL.Record({
|
|
168
|
+
callback: IDL.Func([GetTransactionsRequest], [IDL.Record({ transactions: IDL.Vec(Transaction) })], ['query']),
|
|
169
|
+
start: IDL.Nat,
|
|
170
|
+
length: IDL.Nat
|
|
171
|
+
});
|
|
172
|
+
var GetTransactionsResponse = IDL.Record({
|
|
173
|
+
first_index: IDL.Nat,
|
|
174
|
+
log_length: IDL.Nat,
|
|
175
|
+
transactions: IDL.Vec(Transaction),
|
|
176
|
+
archived_transactions: IDL.Vec(ArchivedTransactionRange)
|
|
177
|
+
});
|
|
178
|
+
return IDL.Service({
|
|
179
|
+
get_transactions: IDL.Func([GetTransactionsRequest], [GetTransactionsResponse], ['query'])
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
start = cursor === null || cursor === void 0 ? void 0 : cursor.next;
|
|
183
|
+
if (!!start) return [3 /*break*/, 2];
|
|
184
|
+
return [4 /*yield*/, actor.get_transactions({
|
|
185
|
+
start: BigInt(0),
|
|
186
|
+
length: BigInt(0)
|
|
187
|
+
})];
|
|
188
|
+
case 1:
|
|
189
|
+
empty = _a.sent();
|
|
190
|
+
start = empty.first_index.toString();
|
|
191
|
+
_a.label = 2;
|
|
192
|
+
case 2:
|
|
193
|
+
next = new bignumber_1.default(start !== null && start !== void 0 ? start : 0);
|
|
194
|
+
hasNext = false;
|
|
195
|
+
_loop_1 = function () {
|
|
196
|
+
var canisterTransactions, ownAddress, defaultFee, transactionsWithIndices, reachedLimit;
|
|
197
|
+
return __generator(this, function (_b) {
|
|
198
|
+
switch (_b.label) {
|
|
199
|
+
case 0: return [4 /*yield*/, actor.get_transactions({
|
|
200
|
+
start: BigInt(next.toString()),
|
|
201
|
+
length: BigInt(limit < 1000 ? limit * 100 : limit)
|
|
202
|
+
})];
|
|
203
|
+
case 1:
|
|
204
|
+
canisterTransactions = _b.sent();
|
|
205
|
+
ownAddress = (0, icrc1_1.getICRC1AddressFromPublicKey)(publicKey.value);
|
|
206
|
+
return [4 /*yield*/, this_1.fee()];
|
|
207
|
+
case 2:
|
|
208
|
+
defaultFee = _b.sent();
|
|
209
|
+
transactionsWithIndices = canisterTransactions.transactions
|
|
210
|
+
.map(function (tx, index) {
|
|
211
|
+
var transaction;
|
|
212
|
+
if (tx.kind === 'transfer' && tx.transfer[0]) {
|
|
213
|
+
var transfer = tx.transfer[0];
|
|
214
|
+
var fromOwner = (0, icrc1_1.getICRC1AddressFromPrincipal)(transfer.from.owner);
|
|
215
|
+
var toOwner = (0, ICPImplementation_1.getAddressFromPrincipal)(transfer.to.owner);
|
|
216
|
+
if (fromOwner !== ownAddress || toOwner !== ownAddress) {
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
219
|
+
var from = (0, ICPImplementation_1.getAddressFromPrincipal)(transfer.from.owner, transfer.from.subaccount);
|
|
220
|
+
var to = (0, ICPImplementation_1.getAddressFromPrincipal)(transfer.to.owner, transfer.to.subaccount);
|
|
221
|
+
transaction = {
|
|
222
|
+
from: [from],
|
|
223
|
+
to: [to],
|
|
224
|
+
isInbound: toOwner === ownAddress,
|
|
225
|
+
amount: (0, module_kit_1.newAmount)(transfer.amount.toString(), 'blockchain'),
|
|
226
|
+
fee: transfer.fee && transfer.fee[0]
|
|
227
|
+
? (0, module_kit_1.newAmount)(transfer.fee[0].toString(), 'blockchain')
|
|
228
|
+
: (0, module_kit_1.newAmount)(defaultFee, 'blockchain'),
|
|
229
|
+
network: _this.options.network,
|
|
230
|
+
status: {
|
|
231
|
+
type: 'applied'
|
|
232
|
+
},
|
|
233
|
+
timestamp: Number(tx.timestamp),
|
|
234
|
+
arbitraryData: transfer.memo && transfer.memo[0] ? Buffer.from(transfer.memo[0]).toString('hex') : undefined
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
else if (tx.kind === 'burn' && tx.burn[0]) {
|
|
238
|
+
var burn = tx.burn[0];
|
|
239
|
+
var fromOwner = (0, ICPImplementation_1.getAddressFromPrincipal)(burn.from.owner);
|
|
240
|
+
if (fromOwner !== ownAddress) {
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
transaction = {
|
|
244
|
+
from: [(0, ICPImplementation_1.getAddressFromPrincipal)(burn.from.owner, burn.from.subaccount)],
|
|
245
|
+
to: ['Burn'],
|
|
246
|
+
isInbound: false,
|
|
247
|
+
amount: (0, module_kit_1.newAmount)(burn.amount.toString(), 'blockchain'),
|
|
248
|
+
fee: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
249
|
+
type: 'burn',
|
|
250
|
+
network: _this.options.network,
|
|
251
|
+
status: {
|
|
252
|
+
type: 'applied'
|
|
253
|
+
},
|
|
254
|
+
timestamp: Number(tx.timestamp),
|
|
255
|
+
arbitraryData: burn.memo && burn.memo[0] ? Buffer.from(burn.memo[0]).toString('hex') : undefined
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
else if (tx.kind === 'mint' && tx.mint[0]) {
|
|
259
|
+
var mint = tx.mint[0];
|
|
260
|
+
var toOwner = (0, ICPImplementation_1.getAddressFromPrincipal)(mint.to.owner);
|
|
261
|
+
if (toOwner !== ownAddress) {
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
transaction = {
|
|
265
|
+
from: ['Mint'],
|
|
266
|
+
to: [(0, ICPImplementation_1.getAddressFromPrincipal)(mint.to.owner, mint.to.subaccount)],
|
|
267
|
+
isInbound: false,
|
|
268
|
+
amount: (0, module_kit_1.newAmount)(mint.amount.toString(), 'blockchain'),
|
|
269
|
+
fee: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
270
|
+
type: 'mint',
|
|
271
|
+
network: _this.options.network,
|
|
272
|
+
status: {
|
|
273
|
+
type: 'applied'
|
|
274
|
+
},
|
|
275
|
+
timestamp: Number(tx.timestamp),
|
|
276
|
+
arbitraryData: mint.memo && mint.memo[0] ? Buffer.from(mint.memo[0]).toString('hex') : undefined
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
return transaction ? [transaction, index] : undefined;
|
|
280
|
+
})
|
|
281
|
+
.filter(function (tx) { return tx !== undefined; });
|
|
282
|
+
reachedLimit = transactionsWithIndices.length > limit;
|
|
283
|
+
transactions = transactionsWithIndices.slice(0, limit).map(function (_a) {
|
|
284
|
+
var _b = __read(_a, 2), tx = _b[0], _ = _b[1];
|
|
285
|
+
return tx;
|
|
286
|
+
});
|
|
287
|
+
next = next.plus(reachedLimit ? transactionsWithIndices[limit - 1][1] + 1 : limit);
|
|
288
|
+
hasNext = next.gte(canisterTransactions.log_length.toString());
|
|
289
|
+
return [2 /*return*/];
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
this_1 = this;
|
|
294
|
+
_a.label = 3;
|
|
295
|
+
case 3: return [5 /*yield**/, _loop_1()];
|
|
296
|
+
case 4:
|
|
297
|
+
_a.sent();
|
|
298
|
+
_a.label = 5;
|
|
299
|
+
case 5:
|
|
300
|
+
if (transactions.length === 0 && hasNext) return [3 /*break*/, 3];
|
|
301
|
+
_a.label = 6;
|
|
302
|
+
case 6: // TODO: collect requested (limit) number of transactions
|
|
303
|
+
return [2 /*return*/, {
|
|
304
|
+
transactions: transactions,
|
|
305
|
+
cursor: {
|
|
306
|
+
hasNext: hasNext,
|
|
307
|
+
next: next.toString()
|
|
308
|
+
}
|
|
309
|
+
}];
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
};
|
|
314
|
+
CkBTCOnlineProtocolImpl.prototype.metadata = function () {
|
|
315
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
316
|
+
var baseMetadata, symbol, name, decimals, fee;
|
|
317
|
+
return __generator(this, function (_a) {
|
|
318
|
+
switch (_a.label) {
|
|
319
|
+
case 0: return [4 /*yield*/, this.baseMetadata()];
|
|
320
|
+
case 1:
|
|
321
|
+
baseMetadata = _a.sent();
|
|
322
|
+
symbol = baseMetadata.symbol, name = baseMetadata.name, decimals = baseMetadata.decimals, fee = baseMetadata.fee;
|
|
323
|
+
return [2 /*return*/, {
|
|
324
|
+
symbol: symbol,
|
|
325
|
+
name: name,
|
|
326
|
+
decimals: decimals,
|
|
327
|
+
fee: fee,
|
|
328
|
+
logo: baseMetadata['icrc1:logo'].Text
|
|
329
|
+
}];
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
};
|
|
334
|
+
return CkBTCOnlineProtocolImpl;
|
|
335
|
+
}(ICRC1Protocol_1.ICRC1OnlineProtocolImpl));
|
|
336
|
+
function createCkBTCOfflineProtocol(options) {
|
|
337
|
+
if (options === void 0) { options = {}; }
|
|
338
|
+
return new CkBTCOfflineProtocolImpl(options);
|
|
339
|
+
}
|
|
340
|
+
exports.createCkBTCOfflineProtocol = createCkBTCOfflineProtocol;
|
|
341
|
+
function createCkBTCOnlineProtocol(options) {
|
|
342
|
+
if (options === void 0) { options = {}; }
|
|
343
|
+
return new CkBTCOnlineProtocolImpl(options);
|
|
344
|
+
}
|
|
345
|
+
exports.createCkBTCOnlineProtocol = createCkBTCOnlineProtocol;
|
|
346
|
+
exports.CKBTC_MAINNET_PROTOCOL_NETWORK = {
|
|
347
|
+
name: 'Mainnet',
|
|
348
|
+
type: 'mainnet',
|
|
349
|
+
rpcUrl: 'https://boundary.ic0.app/',
|
|
350
|
+
canisterId: 'mxzaz-hqaaa-aaaar-qaada-cai',
|
|
351
|
+
explorerUrl: 'https://ledger-api.internetcomputer.org'
|
|
352
|
+
};
|
|
353
|
+
var DEFAULT_CKBTC_PROTOCOL_NETWORK = exports.CKBTC_MAINNET_PROTOCOL_NETWORK;
|
|
354
|
+
function createCkBTCOfflineProtocolOptions(canisterId) {
|
|
355
|
+
return {
|
|
356
|
+
canisterId: canisterId !== null && canisterId !== void 0 ? canisterId : DEFAULT_CKBTC_PROTOCOL_NETWORK.canisterId
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
exports.createCkBTCOfflineProtocolOptions = createCkBTCOfflineProtocolOptions;
|
|
360
|
+
function createCkBTCOnlineProtocolOptions(network) {
|
|
361
|
+
if (network === void 0) { network = {}; }
|
|
362
|
+
return {
|
|
363
|
+
network: __assign(__assign({}, DEFAULT_CKBTC_PROTOCOL_NETWORK), network)
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
exports.createCkBTCOnlineProtocolOptions = createCkBTCOnlineProtocolOptions;
|
|
367
|
+
//# 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,qDAAyD;AACzD,iHAA0F;AAC1F,iDAQ2B;AAO3B,2CAA8F;AAC9F,0DAA8D;AAE9D,iDAA8H;AAO9H,iBAAiB;AAEjB,IAAM,cAAc,GAMhB;IACF,UAAU,EAAE,iCAAkB,CAAC,SAAS;IACxC,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACL,KAAK,EAAE;YACL,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;YAC1B,QAAQ,EAAE,CAAC;SACZ;KACF;IACD,QAAQ,EAAE,OAAO;IACjB,WAAW,EAAE;QACX,GAAG,EAAE,IAAA,sBAAS,EAAC,EAAE,EAAE,YAAY,CAAC;QAChC,MAAM,EAAE,IAAA,sBAAS,EAAC,EAAE,EAAE,YAAY,CAAC;QACnC,IAAI,EAAE,IAAA,sBAAS,EAAC,EAAE,EAAE,YAAY,CAAC;KAClC;CACF,CAAA;AAED;IAAuC,4CAAoC;IACzE,kCAAmB,OAAqD;QACtE,IAAM,eAAe,GAA+B,iCAAiC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;eAEzG,wCACK,eAAe,GACf,cAAc,EACjB;IACJ,CAAC;IACH,+BAAC;AAAD,CAAC,AATD,CAA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TransactionsWithCursor, 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'> {
|
|
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
|
+
getBalanceOfPublicKey(publicKey: PublicKey): Promise<Balance<_Units>>;
|
|
69
|
+
getTransactionMaxAmountWithPublicKey(publicKey: PublicKey, to: string[], configuration?: TransactionConfiguration<_Units>): Promise<Amount<_Units>>;
|
|
70
|
+
getTransactionFeeWithPublicKey(publicKey: PublicKey, details: TransactionDetails<_Units>[]): Promise<Amount<_Units>>;
|
|
71
|
+
prepareTransactionWithPublicKey(publicKey: PublicKey, details: TransactionDetails<_Units>[], configuration?: TransactionConfiguration<_Units>): Promise<ICPUnsignedTransaction>;
|
|
72
|
+
broadcastTransaction(transaction: ICPSignedTransaction): Promise<string>;
|
|
73
|
+
private _name;
|
|
74
|
+
name(): Promise<string>;
|
|
75
|
+
private _symbol;
|
|
76
|
+
symbol(): Promise<string>;
|
|
77
|
+
private _decimals;
|
|
78
|
+
decimals(): Promise<number>;
|
|
79
|
+
private _fee;
|
|
80
|
+
fee(): Promise<string>;
|
|
81
|
+
abstract metadata(): Promise<_ICRC1Metadata>;
|
|
82
|
+
private _baseMetadata;
|
|
83
|
+
protected baseMetadata(): Promise<ICRC1Metadata & Record<string, any>>;
|
|
84
|
+
private _totalSupply;
|
|
85
|
+
totalSupply(): Promise<string>;
|
|
86
|
+
private _mintingAccount;
|
|
87
|
+
mintingAccount(): Promise<ICRC1Account | undefined>;
|
|
88
|
+
balanceOf(account: ICRC1Account): Promise<string>;
|
|
89
|
+
transfer(privateKey: string, args: ICRC1TransferArgs): Promise<string>;
|
|
90
|
+
protected createActor(idlFactory?: IDL.InterfaceFactory, identity?: Identity): ActorSubclass;
|
|
91
|
+
}
|