@airgap/icp 0.13.11-beta.0 → 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/package.json +15 -16
- package/v1/index.d.ts +5 -3
- 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 +13 -5
- package/v1/protocol/ICPImplementation.js +92 -58
- package/v1/protocol/ICPImplementation.js.map +1 -1
- package/v1/protocol/ICPProtocol.d.ts +9 -2
- package/v1/protocol/ICPProtocol.js +44 -35
- package/v1/protocol/ICPProtocol.js.map +1 -1
- 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/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/crypto.d.ts +2 -0
- package/v1/types/crypto.js +3 -0
- package/v1/types/crypto.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 +30 -1
- package/v1/utils/convert.d.ts +3 -1
- package/v1/utils/convert.js +9 -1
- package/v1/utils/convert.js.map +1 -1
- package/v1/utils/hdkey.js +28 -5
- package/v1/utils/hdkey.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
- package/v1/utils/secp256k1.js +31 -7
- package/v1/utils/secp256k1.js.map +1 -1
- package/airgap-coinlib-icp.min.js +0 -91775
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airgap/icp",
|
|
3
|
-
"version": "0.13.11-beta.
|
|
3
|
+
"version": "0.13.11-beta.10",
|
|
4
4
|
"description": "The @airgap/icp is an ICP implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"airgap",
|
|
@@ -24,27 +24,26 @@
|
|
|
24
24
|
"lint:prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
25
25
|
"lint-ci": "tslint -t json -o ../../lint-reports/icp.json --project . || true",
|
|
26
26
|
"lint-ci:prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" --list-different",
|
|
27
|
-
"test": "",
|
|
27
|
+
"test": "TS_NODE_PROJECT='./test/tsconfig.json' nyc mocha --bail --require ts-node/register --require tsconfig-paths/register --require source-map-support/register --full-trace --delay --timeout 40000 ./test/**/**.spec.ts",
|
|
28
28
|
"test-ci": "nyc --reporter=lcov npm test",
|
|
29
|
-
"
|
|
30
|
-
"browserify": "browserify ./dist/index.js -p realpathify -s airgapCoinLibICP > ./dist/airgap-coinlib-icp.min.js"
|
|
29
|
+
"browserify": "browserify ./dist/index.js -s airgapCoinLibICP > ./dist/airgap-coinlib-icp.min.js"
|
|
31
30
|
},
|
|
32
31
|
"author": "Papers GmbH <contact@papers.ch> (https://papers.ch)",
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"@airgap/coinlib-core": "^0.13.10",
|
|
35
|
-
"@airgap/module-kit": "^0.13.10",
|
|
36
|
-
"@airgap/serializer": "^0.13.10",
|
|
37
|
-
"@stablelib/ed25519": "1.0.3"
|
|
38
|
-
},
|
|
39
32
|
"dependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
33
|
+
"@airgap/coinlib-core": "*",
|
|
34
|
+
"@airgap/crypto": "*",
|
|
35
|
+
"@airgap/module-kit": "*",
|
|
36
|
+
"@airgap/serializer": "*",
|
|
37
|
+
"@stablelib/ed25519": "^1.0.3",
|
|
38
|
+
"base64-arraybuffer": "^1.0.2",
|
|
39
|
+
"bip39": "^3.0.4",
|
|
40
|
+
"borc": "^3.0.0",
|
|
41
|
+
"crc": "4.3.2",
|
|
42
|
+
"crc-32": "1.2.2",
|
|
45
43
|
"isomorphic-fetch": "^3.0.0",
|
|
46
44
|
"js-sha256": "^0.9.0",
|
|
47
|
-
"secp256k1": "^5.0.0"
|
|
45
|
+
"secp256k1": "^5.0.0",
|
|
46
|
+
"simple-cbor": "^0.4.1"
|
|
48
47
|
},
|
|
49
48
|
"nyc": {
|
|
50
49
|
"include": [
|
package/v1/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { ICPBlockExplorer } from './block-explorer/ICPBlockExplorer';
|
|
2
2
|
import { ICPModule } from './module/ICPModule';
|
|
3
|
-
import {
|
|
3
|
+
import { createICPProtocol, createICPProtocolOptions, ICPProtocol } from './protocol/ICPProtocol';
|
|
4
|
+
import { CkBTCOfflineProtocol, CkBTCOnlineProtocol, createCkBTCOfflineProtocol, createCkBTCOnlineProtocol } from './protocol/icrc/CkBTCProtocol';
|
|
4
5
|
import { ICPTransactionSignRequest } from './serializer/v3/schemas/definitions/transaction-sign-request-icp';
|
|
5
6
|
import { ICPTransactionSignResponse } from './serializer/v3/schemas/definitions/transaction-sign-response-icp';
|
|
7
|
+
import { ICPCryptoConfiguration } from './types/crypto';
|
|
6
8
|
import { ICPProtocolNetwork, ICPProtocolOptions, ICPUnits } from './types/protocol';
|
|
7
9
|
import { ICPSignedTransaction, ICPUnsignedTransaction } from './types/transaction';
|
|
8
10
|
export { ICPModule };
|
|
9
|
-
export { ICPProtocol, createICPProtocol, createICPProtocolOptions };
|
|
11
|
+
export { ICPProtocol, createICPProtocol, createICPProtocolOptions, CkBTCOfflineProtocol, CkBTCOnlineProtocol, createCkBTCOfflineProtocol, createCkBTCOnlineProtocol };
|
|
10
12
|
export { ICPBlockExplorer };
|
|
11
|
-
export { ICPUnits, ICPProtocolOptions, ICPProtocolNetwork, ICPUnsignedTransaction, ICPSignedTransaction };
|
|
13
|
+
export { ICPCryptoConfiguration, ICPUnits, ICPProtocolOptions, ICPProtocolNetwork, ICPUnsignedTransaction, ICPSignedTransaction };
|
|
12
14
|
export { ICPTransactionSignRequest, ICPTransactionSignResponse };
|
package/v1/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ICPBlockExplorer = exports.createICPProtocolOptions = exports.createICPProtocol = exports.ICPModule = void 0;
|
|
3
|
+
exports.ICPBlockExplorer = exports.createCkBTCOnlineProtocol = exports.createCkBTCOfflineProtocol = exports.createICPProtocolOptions = exports.createICPProtocol = exports.ICPModule = void 0;
|
|
4
4
|
var ICPBlockExplorer_1 = require("./block-explorer/ICPBlockExplorer");
|
|
5
5
|
Object.defineProperty(exports, "ICPBlockExplorer", { enumerable: true, get: function () { return ICPBlockExplorer_1.ICPBlockExplorer; } });
|
|
6
6
|
var ICPModule_1 = require("./module/ICPModule");
|
|
@@ -8,4 +8,7 @@ Object.defineProperty(exports, "ICPModule", { enumerable: true, get: function ()
|
|
|
8
8
|
var ICPProtocol_1 = require("./protocol/ICPProtocol");
|
|
9
9
|
Object.defineProperty(exports, "createICPProtocol", { enumerable: true, get: function () { return ICPProtocol_1.createICPProtocol; } });
|
|
10
10
|
Object.defineProperty(exports, "createICPProtocolOptions", { enumerable: true, get: function () { return ICPProtocol_1.createICPProtocolOptions; } });
|
|
11
|
+
var CkBTCProtocol_1 = require("./protocol/icrc/CkBTCProtocol");
|
|
12
|
+
Object.defineProperty(exports, "createCkBTCOfflineProtocol", { enumerable: true, get: function () { return CkBTCProtocol_1.createCkBTCOfflineProtocol; } });
|
|
13
|
+
Object.defineProperty(exports, "createCkBTCOnlineProtocol", { enumerable: true, get: function () { return CkBTCProtocol_1.createCkBTCOnlineProtocol; } });
|
|
11
14
|
//# sourceMappingURL=index.js.map
|
package/v1/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,sEAAoE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,sEAAoE;AAiC3D,iGAjCA,mCAAgB,OAiCA;AAhCzB,gDAA8C;AAgBrC,0FAhBA,qBAAS,OAgBA;AAflB,sDAAiG;AAqB/F,kGArBO,+BAAiB,OAqBP;AACjB,yGAtB0B,sCAAwB,OAsB1B;AArB1B,+DAKsC;AAmBpC,2GArBA,0CAA0B,OAqBA;AAC1B,0GArBA,yCAAyB,OAqBA"}
|
package/v1/module/ICPModule.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MainProtocolSymbols } from '@airgap/coinlib-core';
|
|
1
|
+
import { MainProtocolSymbols, SubProtocolSymbols } from '@airgap/coinlib-core';
|
|
2
2
|
import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, AirGapV3SerializerCompanion, ProtocolConfiguration } from '@airgap/module-kit';
|
|
3
|
-
declare type SupportedProtocols = MainProtocolSymbols.ICP;
|
|
3
|
+
declare type SupportedProtocols = MainProtocolSymbols.ICP | SubProtocolSymbols.ICP_CKBTC;
|
|
4
4
|
export declare class ICPModule implements AirGapModule<{
|
|
5
5
|
Protocols: SupportedProtocols;
|
|
6
6
|
}> {
|
|
@@ -10,6 +10,5 @@ export declare class ICPModule implements AirGapModule<{
|
|
|
10
10
|
createOfflineProtocol(identifier: SupportedProtocols): Promise<AirGapOfflineProtocol | undefined>;
|
|
11
11
|
createOnlineProtocol(identifier: SupportedProtocols, networkId?: string): Promise<AirGapOnlineProtocol | undefined>;
|
|
12
12
|
createBlockExplorer(identifier: SupportedProtocols, networkId?: string): Promise<AirGapBlockExplorer | undefined>;
|
|
13
|
-
private createProtocol;
|
|
14
13
|
}
|
|
15
14
|
export {};
|
package/v1/module/ICPModule.js
CHANGED
|
@@ -42,6 +42,7 @@ var errors_1 = require("@airgap/coinlib-core/errors");
|
|
|
42
42
|
var module_kit_1 = require("@airgap/module-kit");
|
|
43
43
|
var ICPBlockExplorer_1 = require("../block-explorer/ICPBlockExplorer");
|
|
44
44
|
var ICPProtocol_1 = require("../protocol/ICPProtocol");
|
|
45
|
+
var CkBTCProtocol_1 = require("../protocol/icrc/CkBTCProtocol");
|
|
45
46
|
var serializer_companion_1 = require("../serializer/v3/serializer-companion");
|
|
46
47
|
var ICPModule = /** @class */ (function () {
|
|
47
48
|
function ICPModule() {
|
|
@@ -50,6 +51,9 @@ var ICPModule = /** @class */ (function () {
|
|
|
50
51
|
_a[coinlib_core_1.MainProtocolSymbols.ICP] = new module_kit_1.ModuleNetworkRegistry({
|
|
51
52
|
supportedNetworks: [ICPProtocol_1.ICP_MAINNET_PROTOCOL_NETWORK]
|
|
52
53
|
}),
|
|
54
|
+
_a[coinlib_core_1.SubProtocolSymbols.ICP_CKBTC] = new module_kit_1.ModuleNetworkRegistry({
|
|
55
|
+
supportedNetworks: [CkBTCProtocol_1.CKBTC_MAINNET_PROTOCOL_NETWORK]
|
|
56
|
+
}),
|
|
53
57
|
_a);
|
|
54
58
|
this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
|
|
55
59
|
}
|
|
@@ -63,7 +67,15 @@ var ICPModule = /** @class */ (function () {
|
|
|
63
67
|
ICPModule.prototype.createOfflineProtocol = function (identifier) {
|
|
64
68
|
return __awaiter(this, void 0, void 0, function () {
|
|
65
69
|
return __generator(this, function (_a) {
|
|
66
|
-
|
|
70
|
+
switch (identifier) {
|
|
71
|
+
case coinlib_core_1.MainProtocolSymbols.ICP:
|
|
72
|
+
return [2 /*return*/, (0, ICPProtocol_1.createICPProtocol)()];
|
|
73
|
+
case coinlib_core_1.SubProtocolSymbols.ICP_CKBTC:
|
|
74
|
+
return [2 /*return*/, (0, CkBTCProtocol_1.createCkBTCOfflineProtocol)()];
|
|
75
|
+
default:
|
|
76
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ICP, "Protocol ".concat(identifier, " not supported."));
|
|
77
|
+
}
|
|
78
|
+
return [2 /*return*/];
|
|
67
79
|
});
|
|
68
80
|
});
|
|
69
81
|
};
|
|
@@ -76,7 +88,15 @@ var ICPModule = /** @class */ (function () {
|
|
|
76
88
|
if (network === undefined) {
|
|
77
89
|
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ICP, 'Protocol network not supported.');
|
|
78
90
|
}
|
|
79
|
-
|
|
91
|
+
switch (identifier) {
|
|
92
|
+
case coinlib_core_1.MainProtocolSymbols.ICP:
|
|
93
|
+
return [2 /*return*/, (0, ICPProtocol_1.createICPProtocol)({ network: network })];
|
|
94
|
+
case coinlib_core_1.SubProtocolSymbols.ICP_CKBTC:
|
|
95
|
+
return [2 /*return*/, (0, CkBTCProtocol_1.createCkBTCOnlineProtocol)({ network: network })];
|
|
96
|
+
default:
|
|
97
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ICP, "Protocol ".concat(identifier, " not supported."));
|
|
98
|
+
}
|
|
99
|
+
return [2 /*return*/];
|
|
80
100
|
});
|
|
81
101
|
});
|
|
82
102
|
};
|
|
@@ -93,14 +113,6 @@ var ICPModule = /** @class */ (function () {
|
|
|
93
113
|
});
|
|
94
114
|
});
|
|
95
115
|
};
|
|
96
|
-
ICPModule.prototype.createProtocol = function (identifier, network) {
|
|
97
|
-
switch (identifier) {
|
|
98
|
-
case coinlib_core_1.MainProtocolSymbols.ICP:
|
|
99
|
-
return (0, ICPProtocol_1.createICPProtocol)({ network: network });
|
|
100
|
-
default:
|
|
101
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ICP, "Protocol ".concat(identifier, " not supported."));
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
116
|
return ICPModule;
|
|
105
117
|
}());
|
|
106
118
|
exports.ICPModule = ICPModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICPModule.js","sourceRoot":"","sources":["../../../src/v1/module/ICPModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"ICPModule.js","sourceRoot":"","sources":["../../../src/v1/module/ICPModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsF;AACtF,sDAAqE;AACrE,iDAU2B;AAE3B,uEAAqE;AACrE,uDAAyF;AACzF,gEAAsI;AACtI,8EAAgF;AAIhF;IAAA;;QACmB,sBAAiB;YAChC,GAAC,kCAAmB,CAAC,GAAG,IAAG,IAAI,kCAAqB,CAAC;gBACnD,iBAAiB,EAAE,CAAC,0CAA4B,CAAC;aAClD,CAAC;YACF,GAAC,iCAAkB,CAAC,SAAS,IAAG,IAAI,kCAAqB,CAAC;gBACxD,iBAAiB,EAAE,CAAC,8CAA8B,CAAC;aACpD,CAAC;gBACH;QACe,uBAAkB,GAA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0CAAE,WAAW,CAAC,SAAS,CAAC,CAAA;gBACvG,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,SAAS,EAAE;oBAC/B,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,GAAG,EAAE,uCAAuC,CAAC,CAAA;iBACvF;gBAED,sBAAO,IAAI,mCAAgB,EAAE,EAAA;;;KAC9B;IACH,gBAAC;AAAD,CAAC,AAlDD,IAkDC;AAlDY,8BAAS"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import 'isomorphic-fetch';
|
|
3
|
+
import { Identity } from '../utils/auth';
|
|
4
|
+
import { HttpAgent } from '../utils/http';
|
|
5
|
+
import { Principal } from '../utils/principal';
|
|
2
6
|
interface Transaction {
|
|
3
7
|
to: string;
|
|
4
8
|
amount: bigint;
|
|
5
9
|
fee: bigint;
|
|
6
10
|
}
|
|
7
|
-
export declare function
|
|
11
|
+
export declare function createHttpAgent(rpcUrl: string, identity?: Identity): HttpAgent;
|
|
12
|
+
export declare function getKeyPairFromExtendedSecretKey(extendedSecretKey: string): {
|
|
8
13
|
publicKey: string;
|
|
9
14
|
privateKey: string;
|
|
10
15
|
};
|
|
11
|
-
export declare function
|
|
16
|
+
export declare function getPrincipalFromPublicKey(publicKey: string): Principal;
|
|
17
|
+
export declare function getAddressFromPublicKey(publicKey: string, subAccount?: string | Buffer | Uint8Array): string;
|
|
18
|
+
export declare function getAddressFromPrincipal(principalOrText: Principal | string, subAccountOrUndefined?: string | Buffer | Uint8Array): string;
|
|
12
19
|
export declare function createUnsignedTransaction(transaction: Transaction): string;
|
|
13
20
|
export declare function getInfoFromUnsignedTransaction(unsignedTransaction: string): {
|
|
14
21
|
to: string;
|
|
@@ -18,9 +25,10 @@ export declare function getInfoFromUnsignedTransaction(unsignedTransaction: stri
|
|
|
18
25
|
created_at_time: any[];
|
|
19
26
|
amount: bigint;
|
|
20
27
|
};
|
|
21
|
-
export declare function
|
|
28
|
+
export declare function signICPTransaction(unsignedTransaction: string, privateKey: string, canisterId: string): Promise<string>;
|
|
29
|
+
export declare function signTransaction(privateKey: string, canisterId: string, arg: any): Promise<string>;
|
|
22
30
|
export declare function getInfoFromSignedTransaction(signedTransaction: string): any;
|
|
23
31
|
export declare function decodeArguments(args: ArrayBuffer): any;
|
|
24
|
-
export declare function getBalanceFromAddress(address: string, host: string): Promise<bigint>;
|
|
25
|
-
export declare function broadcastTransaction(signedTransaction: string, host: string): Promise<string>;
|
|
32
|
+
export declare function getBalanceFromAddress(address: string, host: string, canisterId: string): Promise<bigint>;
|
|
33
|
+
export declare function broadcastTransaction(signedTransaction: string, host: string, canisterId: string): Promise<string>;
|
|
26
34
|
export {};
|
|
@@ -98,23 +98,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
98
98
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
99
99
|
};
|
|
100
100
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
101
|
-
exports.broadcastTransaction = exports.getBalanceFromAddress = exports.decodeArguments = exports.getInfoFromSignedTransaction = exports.signTransaction = exports.getInfoFromUnsignedTransaction = exports.createUnsignedTransaction = exports.getAddressFromPublicKey = exports.
|
|
101
|
+
exports.broadcastTransaction = exports.getBalanceFromAddress = exports.decodeArguments = exports.getInfoFromSignedTransaction = exports.signTransaction = exports.signICPTransaction = exports.getInfoFromUnsignedTransaction = exports.createUnsignedTransaction = exports.getAddressFromPrincipal = exports.getAddressFromPublicKey = exports.getPrincipalFromPublicKey = exports.getKeyPairFromExtendedSecretKey = exports.createHttpAgent = void 0;
|
|
102
|
+
var index_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0/index"));
|
|
103
|
+
var hex_1 = require("@airgap/coinlib-core/utils/hex");
|
|
102
104
|
require("isomorphic-fetch");
|
|
103
|
-
var convert_1 = require("../utils/convert");
|
|
104
105
|
var js_sha256_1 = require("js-sha256");
|
|
105
106
|
var ledger_1 = require("../types/ledger");
|
|
106
|
-
var index_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0/index"));
|
|
107
|
-
var IDL = __importStar(require("../utils/idl"));
|
|
108
|
-
var principal_1 = require("../utils/principal");
|
|
109
|
-
var secp256k1_1 = __importDefault(require("../utils/secp256k1"));
|
|
110
|
-
var http_1 = require("../utils/http");
|
|
111
107
|
var account_1 = require("../utils/account");
|
|
112
108
|
// import { requestIdOf } from '../utils/auth'
|
|
113
109
|
var actor_1 = require("../utils/actor");
|
|
110
|
+
var auth_1 = require("../utils/auth");
|
|
114
111
|
var Cbor = __importStar(require("../utils/cbor"));
|
|
112
|
+
var convert_1 = require("../utils/convert");
|
|
113
|
+
var hdkey_1 = __importDefault(require("../utils/hdkey"));
|
|
114
|
+
var http_1 = require("../utils/http");
|
|
115
|
+
var IDL = __importStar(require("../utils/idl"));
|
|
116
|
+
var principal_1 = require("../utils/principal");
|
|
117
|
+
var secp256k1_1 = __importDefault(require("../utils/secp256k1"));
|
|
118
|
+
// Agent
|
|
119
|
+
function createHttpAgent(rpcUrl, identity) {
|
|
120
|
+
if (identity === void 0) { identity = new auth_1.AnonymousIdentity(); }
|
|
121
|
+
return new http_1.HttpAgent({
|
|
122
|
+
identity: identity,
|
|
123
|
+
host: rpcUrl
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
exports.createHttpAgent = createHttpAgent;
|
|
115
127
|
// MNEMONIC -> KEY PAIR
|
|
116
|
-
function
|
|
117
|
-
var
|
|
128
|
+
function getKeyPairFromExtendedSecretKey(extendedSecretKey) {
|
|
129
|
+
var hdKey = hdkey_1.default.fromExtendedKey(extendedSecretKey);
|
|
130
|
+
var identity = secp256k1_1.default.fromSecretKey(hdKey.privateKey);
|
|
118
131
|
var publicKey = new Uint8Array(identity.getPublicKey().toDer());
|
|
119
132
|
var privateKey = new Uint8Array(identity.getKeyPair().secretKey);
|
|
120
133
|
return {
|
|
@@ -122,22 +135,40 @@ function getKeyPairFromMnemonic(mnemonic, derivationPath) {
|
|
|
122
135
|
privateKey: (0, convert_1.uint8ArrayToHexString)(privateKey)
|
|
123
136
|
};
|
|
124
137
|
}
|
|
125
|
-
exports.
|
|
138
|
+
exports.getKeyPairFromExtendedSecretKey = getKeyPairFromExtendedSecretKey;
|
|
126
139
|
// PUBLIC KEY -> ADDRESS
|
|
140
|
+
function getPrincipalFromPublicKey(publicKey) {
|
|
141
|
+
return principal_1.Principal.selfAuthenticating((0, convert_1.hexStringToUint8Array)(publicKey));
|
|
142
|
+
}
|
|
143
|
+
exports.getPrincipalFromPublicKey = getPrincipalFromPublicKey;
|
|
127
144
|
function getAddressFromPublicKey(publicKey, subAccount) {
|
|
128
145
|
// Get principal from public key
|
|
129
|
-
var principal =
|
|
146
|
+
var principal = getPrincipalFromPublicKey(publicKey);
|
|
147
|
+
return getAddressFromPrincipal(principal, subAccount);
|
|
148
|
+
}
|
|
149
|
+
exports.getAddressFromPublicKey = getAddressFromPublicKey;
|
|
150
|
+
function getAddressFromPrincipal(principalOrText, subAccountOrUndefined) {
|
|
151
|
+
var principal = typeof principalOrText === 'string'
|
|
152
|
+
? (0, hex_1.isHex)(principalOrText)
|
|
153
|
+
? principal_1.Principal.fromHex(principalOrText)
|
|
154
|
+
: principal_1.Principal.from(principalOrText)
|
|
155
|
+
: principalOrText;
|
|
156
|
+
var subAccount = typeof subAccountOrUndefined === 'string'
|
|
157
|
+
? Buffer.from(subAccountOrUndefined, 'hex')
|
|
158
|
+
: typeof subAccountOrUndefined === 'undefined' || subAccountOrUndefined.length === 0
|
|
159
|
+
? Buffer.alloc(32, 0)
|
|
160
|
+
: subAccountOrUndefined;
|
|
130
161
|
// Hash (sha224) the principal, the subAccount and some padding
|
|
131
162
|
var padding = (0, convert_1.asciiStringToByteArray)('\x0Aaccount-id');
|
|
132
163
|
var shaObj = js_sha256_1.sha224.create();
|
|
133
|
-
shaObj.update(__spreadArray(__spreadArray(__spreadArray([], __read(padding), false), __read(principal.toUint8Array()), false), __read(
|
|
164
|
+
shaObj.update(__spreadArray(__spreadArray(__spreadArray([], __read(padding), false), __read(principal.toUint8Array()), false), __read(subAccount), false));
|
|
134
165
|
var hash = new Uint8Array(shaObj.array());
|
|
135
166
|
// Prepend the checksum of the hash and convert to a hex string
|
|
136
167
|
var checksum = (0, convert_1.calculateCrc32)(hash);
|
|
137
168
|
var bytes = new Uint8Array(__spreadArray(__spreadArray([], __read(checksum), false), __read(hash), false));
|
|
138
169
|
return (0, convert_1.uint8ArrayToHexString)(bytes);
|
|
139
170
|
}
|
|
140
|
-
exports.
|
|
171
|
+
exports.getAddressFromPrincipal = getAddressFromPrincipal;
|
|
141
172
|
// TRANSACTION OBJECT -> UNSIGNED TRANSACTION HEX
|
|
142
173
|
function createUnsignedTransaction(transaction) {
|
|
143
174
|
var to = account_1.AccountIdentifier.fromHex(transaction.to);
|
|
@@ -172,50 +203,57 @@ function getInfoFromUnsignedTransaction(unsignedTransaction) {
|
|
|
172
203
|
}
|
|
173
204
|
exports.getInfoFromUnsignedTransaction = getInfoFromUnsignedTransaction;
|
|
174
205
|
// UNSIGNED TRANSACTION, PRIVATE KEY -> SIGNED TRANSACTION
|
|
175
|
-
function
|
|
206
|
+
function signICPTransaction(unsignedTransaction, privateKey, canisterId) {
|
|
176
207
|
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
-
var
|
|
208
|
+
var transactionDetails, Address, ICP, Memo, SubAccount, TimeStamp, TransferArgs, DEFAULT_TRANSACTION_FEE, toTransferRawRequest, rawRequestBody, args;
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
transactionDetails = getInfoFromUnsignedTransaction(unsignedTransaction);
|
|
211
|
+
Address = IDL.Vec(IDL.Nat8);
|
|
212
|
+
ICP = IDL.Record({ e8s: IDL.Nat64 });
|
|
213
|
+
Memo = IDL.Nat64;
|
|
214
|
+
SubAccount = IDL.Vec(IDL.Nat8);
|
|
215
|
+
TimeStamp = IDL.Record({ timestamp_nanos: IDL.Nat64 });
|
|
216
|
+
TransferArgs = IDL.Record({
|
|
217
|
+
to: Address,
|
|
218
|
+
fee: ICP,
|
|
219
|
+
memo: Memo,
|
|
220
|
+
from_subaccount: IDL.Opt(SubAccount),
|
|
221
|
+
created_at_time: IDL.Opt(TimeStamp),
|
|
222
|
+
amount: ICP
|
|
223
|
+
});
|
|
224
|
+
DEFAULT_TRANSACTION_FEE = BigInt(10000);
|
|
225
|
+
toTransferRawRequest = function (_a) {
|
|
226
|
+
var to = _a.to, amount = _a.amount, memo = _a.memo, fee = _a.fee, fromSubAccount = _a.fromSubAccount;
|
|
227
|
+
return {
|
|
228
|
+
to: to.toNumbers(),
|
|
229
|
+
fee: (0, convert_1.e8sToTokens)(fee !== null && fee !== void 0 ? fee : DEFAULT_TRANSACTION_FEE),
|
|
230
|
+
amount: (0, convert_1.e8sToTokens)(amount),
|
|
231
|
+
// Always explicitly set the memo for compatibility with ledger wallet - hardware wallet
|
|
232
|
+
memo: memo !== null && memo !== void 0 ? memo : BigInt(0),
|
|
233
|
+
created_at_time: [],
|
|
234
|
+
from_subaccount: fromSubAccount === undefined ? [] : [fromSubAccount]
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
rawRequestBody = toTransferRawRequest(__assign(__assign({}, transactionDetails), { to: account_1.AccountIdentifier.fromHex(transactionDetails.to) }));
|
|
238
|
+
args = IDL.encode([TransferArgs], [rawRequestBody]);
|
|
239
|
+
return [2 /*return*/, signTransaction(privateKey, canisterId, args)];
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
exports.signICPTransaction = signICPTransaction;
|
|
244
|
+
function signTransaction(privateKey, canisterId, arg) {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
+
var identity, submit, transform, request, transformedRequest, encoded;
|
|
178
247
|
var _this = this;
|
|
179
248
|
return __generator(this, function (_a) {
|
|
180
249
|
switch (_a.label) {
|
|
181
250
|
case 0:
|
|
182
251
|
identity = secp256k1_1.default.fromSecretKey((0, convert_1.hexStringToArrayBuffer)(privateKey));
|
|
183
|
-
transactionDetails = getInfoFromUnsignedTransaction(unsignedTransaction);
|
|
184
|
-
Address = IDL.Vec(IDL.Nat8);
|
|
185
|
-
ICP = IDL.Record({ e8s: IDL.Nat64 });
|
|
186
|
-
Memo = IDL.Nat64;
|
|
187
|
-
SubAccount = IDL.Vec(IDL.Nat8);
|
|
188
|
-
TimeStamp = IDL.Record({ timestamp_nanos: IDL.Nat64 });
|
|
189
|
-
TransferArgs = IDL.Record({
|
|
190
|
-
to: Address,
|
|
191
|
-
fee: ICP,
|
|
192
|
-
memo: Memo,
|
|
193
|
-
from_subaccount: IDL.Opt(SubAccount),
|
|
194
|
-
created_at_time: IDL.Opt(TimeStamp),
|
|
195
|
-
amount: ICP
|
|
196
|
-
});
|
|
197
|
-
DEFAULT_TRANSACTION_FEE = BigInt(10000);
|
|
198
|
-
toTransferRawRequest = function (_a) {
|
|
199
|
-
var to = _a.to, amount = _a.amount, memo = _a.memo, fee = _a.fee, fromSubAccount = _a.fromSubAccount;
|
|
200
|
-
return {
|
|
201
|
-
to: to.toNumbers(),
|
|
202
|
-
fee: (0, convert_1.e8sToTokens)(fee !== null && fee !== void 0 ? fee : DEFAULT_TRANSACTION_FEE),
|
|
203
|
-
amount: (0, convert_1.e8sToTokens)(amount),
|
|
204
|
-
// Always explicitly set the memo for compatibility with ledger wallet - hardware wallet
|
|
205
|
-
memo: memo !== null && memo !== void 0 ? memo : BigInt(0),
|
|
206
|
-
created_at_time: [],
|
|
207
|
-
from_subaccount: fromSubAccount === undefined ? [] : [fromSubAccount]
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
rawRequestBody = toTransferRawRequest(__assign(__assign({}, transactionDetails), { to: account_1.AccountIdentifier.fromHex(transactionDetails.to) }));
|
|
211
|
-
args = IDL.encode([TransferArgs], [rawRequestBody]);
|
|
212
252
|
submit = {
|
|
213
253
|
request_type: http_1.SubmitRequestType.Call,
|
|
214
|
-
|
|
215
|
-
canister_id: principal_1.Principal.from(ledger_1.canisterId),
|
|
254
|
+
canister_id: principal_1.Principal.from(canisterId),
|
|
216
255
|
method_name: 'transfer',
|
|
217
|
-
arg:
|
|
218
|
-
//@ts-ignore
|
|
256
|
+
arg: arg,
|
|
219
257
|
sender: identity.getPrincipal(),
|
|
220
258
|
ingress_expiry: new http_1.Expiry(5 * 60 * 1000)
|
|
221
259
|
};
|
|
@@ -272,20 +310,16 @@ function decodeArguments(args) {
|
|
|
272
310
|
}
|
|
273
311
|
exports.decodeArguments = decodeArguments;
|
|
274
312
|
// ADDRESS -> BALANCE
|
|
275
|
-
function getBalanceFromAddress(address, host) {
|
|
313
|
+
function getBalanceFromAddress(address, host, canisterId) {
|
|
276
314
|
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
-
var
|
|
315
|
+
var agent, actor, acc, b;
|
|
278
316
|
return __generator(this, function (_a) {
|
|
279
317
|
switch (_a.label) {
|
|
280
318
|
case 0:
|
|
281
|
-
|
|
282
|
-
agent = new http_1.HttpAgent({
|
|
283
|
-
identity: identity,
|
|
284
|
-
host: host
|
|
285
|
-
});
|
|
319
|
+
agent = createHttpAgent(host, secp256k1_1.default.generate());
|
|
286
320
|
actor = actor_1.Actor.createActor(ledger_1.idlFactory, {
|
|
287
321
|
agent: agent,
|
|
288
|
-
canisterId:
|
|
322
|
+
canisterId: canisterId
|
|
289
323
|
});
|
|
290
324
|
acc = Uint8Array.from(Buffer.from(address, 'hex'));
|
|
291
325
|
return [4 /*yield*/, actor.account_balance({
|
|
@@ -299,13 +333,13 @@ function getBalanceFromAddress(address, host) {
|
|
|
299
333
|
});
|
|
300
334
|
}
|
|
301
335
|
exports.getBalanceFromAddress = getBalanceFromAddress;
|
|
302
|
-
function broadcastTransaction(signedTransaction, host) {
|
|
336
|
+
function broadcastTransaction(signedTransaction, host, canisterId) {
|
|
303
337
|
return __awaiter(this, void 0, void 0, function () {
|
|
304
338
|
var canister, body, error_1;
|
|
305
339
|
return __generator(this, function (_a) {
|
|
306
340
|
switch (_a.label) {
|
|
307
341
|
case 0:
|
|
308
|
-
canister = principal_1.Principal.from(
|
|
342
|
+
canister = principal_1.Principal.from(canisterId);
|
|
309
343
|
body = (0, convert_1.hexStringToArrayBuffer)(signedTransaction);
|
|
310
344
|
_a.label = 1;
|
|
311
345
|
case 1:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICPImplementation.js","sourceRoot":"","sources":["../../../src/v1/protocol/ICPImplementation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAAyB;
|
|
1
|
+
{"version":3,"file":"ICPImplementation.js","sourceRoot":"","sources":["../../../src/v1/protocol/ICPImplementation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mGAA4E;AAC5E,sDAAsD;AACtD,4BAAyB;AACzB,uCAAkC;AAElC,0CAA4E;AAC5E,4CAAoD;AACpD,8CAA8C;AAC9C,wCAAsC;AACtC,sCAA2D;AAC3D,kDAAqC;AACrC,4CAQyB;AACzB,yDAAkC;AAClC,sCASsB;AACtB,gDAAmC;AACnC,gDAA8C;AAC9C,iEAAqD;AAQrD,QAAQ;AAER,SAAgB,eAAe,CAAC,MAAc,EAAE,QAA4C;IAA5C,yBAAA,EAAA,eAAyB,wBAAiB,EAAE;IAC1F,OAAO,IAAI,gBAAS,CAAC;QACnB,QAAQ,UAAA;QACR,IAAI,EAAE,MAAM;KACb,CAAC,CAAA;AACJ,CAAC;AALD,0CAKC;AAED,uBAAuB;AACvB,SAAgB,+BAA+B,CAAC,iBAAyB;IACvE,IAAM,KAAK,GAAG,eAAK,CAAC,eAAe,CAAC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AG,SAAC;yBAClB,CAAC,EAAA;;oBAFI,CAAC,GAAG,CAAC,SAET,CAAoB;oBACtB,sBAAO,CAAC,CAAC,GAAG,EAAA;;;;CACb;AAbD,sDAaC;AAED,SAAsB,oBAAoB,CAAC,iBAAyB,EAAE,IAAY,EAAE,UAAkB;;;;;;oBAC9F,QAAQ,GAAG,qBAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;oBAErC,IAAI,GAAG,IAAA,gCAAsB,EAAC,iBAAiB,CAAC,CAAA;;;;oBAIpD,oBAAoB,CAAC,qBAAM,eAAK,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,2BAAoB,QAAQ,CAAC,MAAM,EAAE,UAAO,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE;4BAC5G,OAAO,EAAE;gCACP,cAAc,EAAE,kBAAkB;6BACnC;yBACF,CAAC;wBAEF,gCAAgC;wBAChC,sCAAsC;wBACtC,qCAAqC;wBACrC,IAAI;wBAEJ,oDAAoD;sBAPlD;;oBAJF,oBAAoB,CAAC,SAInB,CAAA;oBAEF,gCAAgC;oBAChC,sCAAsC;oBACtC,qCAAqC;oBACrC,IAAI;oBAEJ,oDAAoD;oBAEpD,sBAAO,EAAE,EAAA;;;oBAET,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,OAAK,CAAC,CAAA;oBAC/B,sBAAO,EAAE,EAAA;;;;;CAEZ;AAzBD,oDAyBC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { Address, AirGapProtocol, AirGapTransaction, AirGapTransactionsWithCursor, Amount, Balance, FeeDefaults, KeyPair, ProtocolMetadata, PublicKey, RecursivePartial,
|
|
1
|
+
import { Address, AirGapProtocol, AirGapTransaction, AirGapTransactionsWithCursor, Amount, Balance, CryptoDerivative, FeeDefaults, KeyPair, ProtocolAccountMetadata, ProtocolMetadata, ProtocolTransactionMetadata, PublicKey, RecursivePartial, SecretKey, TransactionConfiguration, TransactionDetails } from '@airgap/module-kit';
|
|
2
|
+
import { ICPCryptoConfiguration } from '../types/crypto';
|
|
2
3
|
import { ICPProtocolNetwork, ICPProtocolOptions, ICPUnits } from '../types/protocol';
|
|
3
4
|
import { ICPSignedTransaction, ICPTransactionCursor, ICPUnsignedTransaction } from '../types/transaction';
|
|
4
5
|
export interface ICPProtocol extends AirGapProtocol<{
|
|
5
6
|
AddressResult: Address;
|
|
6
7
|
ProtocolNetwork: ICPProtocolNetwork;
|
|
8
|
+
CryptoConfiguration: ICPCryptoConfiguration;
|
|
7
9
|
SignedTransaction: ICPSignedTransaction;
|
|
8
10
|
TransactionCursor: ICPTransactionCursor;
|
|
9
11
|
Units: ICPUnits;
|
|
@@ -11,6 +13,9 @@ export interface ICPProtocol extends AirGapProtocol<{
|
|
|
11
13
|
UnsignedTransaction: ICPUnsignedTransaction;
|
|
12
14
|
}, 'FetchDataForAddress'> {
|
|
13
15
|
}
|
|
16
|
+
export declare const ICP_DERIVATION_PATH: string;
|
|
17
|
+
export declare const ICP_ACCOUNT_METADATA: ProtocolAccountMetadata;
|
|
18
|
+
export declare function ICP_TRANSACTION_METADATA<_Units extends string = ICPUnits>(): ProtocolTransactionMetadata<_Units>;
|
|
14
19
|
export declare class ICPProtocolImpl implements ICPProtocol {
|
|
15
20
|
private readonly options;
|
|
16
21
|
constructor(options?: RecursivePartial<ICPProtocolOptions>);
|
|
@@ -20,7 +25,9 @@ export declare class ICPProtocolImpl implements ICPProtocol {
|
|
|
20
25
|
getMetadata(): Promise<ProtocolMetadata<ICPUnits>>;
|
|
21
26
|
getAddressFromPublicKey(publicKey: PublicKey): Promise<string>;
|
|
22
27
|
getDetailsFromTransaction(transaction: ICPSignedTransaction | ICPUnsignedTransaction, _publicKey: PublicKey): Promise<AirGapTransaction<ICPUnits>[]>;
|
|
23
|
-
|
|
28
|
+
private readonly cryptoConfiguration;
|
|
29
|
+
getCryptoConfiguration(): Promise<ICPCryptoConfiguration>;
|
|
30
|
+
getKeyPairFromDerivative(derivative: CryptoDerivative): Promise<KeyPair>;
|
|
24
31
|
signTransactionWithSecretKey(transaction: ICPUnsignedTransaction, secretKey: SecretKey): Promise<ICPSignedTransaction>;
|
|
25
32
|
getNetwork(): Promise<ICPProtocolNetwork>;
|
|
26
33
|
getTransactionsForPublicKey(publicKey: PublicKey, limit: number, cursor?: ICPTransactionCursor): Promise<AirGapTransactionsWithCursor<ICPTransactionCursor, ICPUnits>>;
|