@airgap/icp 0.13.11-beta.1 → 0.13.11-beta.3

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.
Files changed (120) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +18 -0
  3. package/index.js.map +1 -0
  4. package/package.json +4 -8
  5. package/v1/block-explorer/ICPBlockExplorer.d.ts +9 -0
  6. package/v1/block-explorer/ICPBlockExplorer.js +74 -0
  7. package/v1/block-explorer/ICPBlockExplorer.js.map +1 -0
  8. package/v1/index.d.ts +13 -0
  9. package/v1/index.js +11 -0
  10. package/v1/index.js.map +1 -0
  11. package/v1/module/ICPModule.d.ts +15 -0
  12. package/v1/module/ICPModule.js +107 -0
  13. package/v1/module/ICPModule.js.map +1 -0
  14. package/v1/module.d.ts +3 -0
  15. package/v1/module.js +24 -0
  16. package/v1/module.js.map +1 -0
  17. package/v1/protocol/ICPImplementation.d.ts +26 -0
  18. package/v1/protocol/ICPImplementation.js +344 -0
  19. package/v1/protocol/ICPImplementation.js.map +1 -0
  20. package/v1/protocol/ICPProtocol.d.ts +42 -0
  21. package/v1/protocol/ICPProtocol.js +416 -0
  22. package/v1/protocol/ICPProtocol.js.map +1 -0
  23. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +7 -0
  24. package/v1/serializer/v3/schemas/converter/transaction-converter.js +21 -0
  25. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
  26. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.d.ts +4 -0
  27. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.js +3 -0
  28. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.js.map +1 -0
  29. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.d.ts +3 -0
  30. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.js +3 -0
  31. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.js.map +1 -0
  32. package/v1/serializer/v3/schemas/generated/transaction-sign-request-icp.json +32 -0
  33. package/v1/serializer/v3/schemas/generated/transaction-sign-response-icp.json +19 -0
  34. package/v1/serializer/v3/serializer-companion.d.ts +14 -0
  35. package/v1/serializer/v3/serializer-companion.js +174 -0
  36. package/v1/serializer/v3/serializer-companion.js.map +1 -0
  37. package/v1/serializer/v3/validators/transaction-validator.d.ts +10 -0
  38. package/v1/serializer/v3/validators/transaction-validator.js +100 -0
  39. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
  40. package/v1/serializer/v3/validators/validators.d.ts +5 -0
  41. package/v1/serializer/v3/validators/validators.js +106 -0
  42. package/v1/serializer/v3/validators/validators.js.map +1 -0
  43. package/v1/types/crypto.d.ts +2 -0
  44. package/v1/types/crypto.js +3 -0
  45. package/v1/types/crypto.js.map +1 -0
  46. package/v1/types/governance.d.ts +580 -0
  47. package/v1/types/governance.js +796 -0
  48. package/v1/types/governance.js.map +1 -0
  49. package/v1/types/ledger.d.ts +143 -0
  50. package/v1/types/ledger.js +146 -0
  51. package/v1/types/ledger.js.map +1 -0
  52. package/v1/types/management_idl.d.ts +7 -0
  53. package/v1/types/management_idl.js +72 -0
  54. package/v1/types/management_idl.js.map +1 -0
  55. package/v1/types/protocol.d.ts +8 -0
  56. package/v1/types/protocol.js +3 -0
  57. package/v1/types/protocol.js.map +1 -0
  58. package/v1/types/transaction.d.ts +11 -0
  59. package/v1/types/transaction.js +3 -0
  60. package/v1/types/transaction.js.map +1 -0
  61. package/v1/utils/account.d.ts +24 -0
  62. package/v1/utils/account.js +112 -0
  63. package/v1/utils/account.js.map +1 -0
  64. package/v1/utils/actor.d.ts +246 -0
  65. package/v1/utils/actor.js +458 -0
  66. package/v1/utils/actor.js.map +1 -0
  67. package/v1/utils/agent.d.ts +156 -0
  68. package/v1/utils/agent.js +16 -0
  69. package/v1/utils/agent.js.map +1 -0
  70. package/v1/utils/auth.d.ts +110 -0
  71. package/v1/utils/auth.js +261 -0
  72. package/v1/utils/auth.js.map +1 -0
  73. package/v1/utils/bls.d.ts +38 -0
  74. package/v1/utils/bls.js +204 -0
  75. package/v1/utils/bls.js.map +1 -0
  76. package/v1/utils/buffer.d.ts +70 -0
  77. package/v1/utils/buffer.js +216 -0
  78. package/v1/utils/buffer.js.map +1 -0
  79. package/v1/utils/cbor.d.ts +9 -0
  80. package/v1/utils/cbor.js +178 -0
  81. package/v1/utils/cbor.js.map +1 -0
  82. package/v1/utils/certificate.d.ts +74 -0
  83. package/v1/utils/certificate.js +396 -0
  84. package/v1/utils/certificate.js.map +1 -0
  85. package/v1/utils/convert.d.ts +8 -0
  86. package/v1/utils/convert.js +80 -0
  87. package/v1/utils/convert.js.map +1 -0
  88. package/v1/utils/crypto.d.ts +0 -0
  89. package/v1/utils/crypto.js +104 -0
  90. package/v1/utils/crypto.js.map +1 -0
  91. package/v1/utils/der.d.ts +35 -0
  92. package/v1/utils/der.js +176 -0
  93. package/v1/utils/der.js.map +1 -0
  94. package/v1/utils/errors.d.ts +7 -0
  95. package/v1/utils/errors.js +38 -0
  96. package/v1/utils/errors.js.map +1 -0
  97. package/v1/utils/hdkey.d.ts +13 -0
  98. package/v1/utils/hdkey.js +265 -0
  99. package/v1/utils/hdkey.js.map +1 -0
  100. package/v1/utils/http.d.ts +284 -0
  101. package/v1/utils/http.js +614 -0
  102. package/v1/utils/http.js.map +1 -0
  103. package/v1/utils/idl.d.ts +515 -0
  104. package/v1/utils/idl.js +2103 -0
  105. package/v1/utils/idl.js.map +1 -0
  106. package/v1/utils/leb128.d.ts +63 -0
  107. package/v1/utils/leb128.js +224 -0
  108. package/v1/utils/leb128.js.map +1 -0
  109. package/v1/utils/polling.d.ts +59 -0
  110. package/v1/utils/polling.js +325 -0
  111. package/v1/utils/polling.js.map +1 -0
  112. package/v1/utils/principal.d.ts +58 -0
  113. package/v1/utils/principal.js +543 -0
  114. package/v1/utils/principal.js.map +1 -0
  115. package/v1/utils/secp256k1.d.ts +79 -0
  116. package/v1/utils/secp256k1.js +278 -0
  117. package/v1/utils/secp256k1.js.map +1 -0
  118. package/v1/utils/transaction.d.ts +3 -0
  119. package/v1/utils/transaction.js +56 -0
  120. package/v1/utils/transaction.js.map +1 -0
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './v1';
package/index.js ADDED
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./v1"), exports);
18
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airgap/icp",
3
- "version": "0.13.11-beta.1",
3
+ "version": "0.13.11-beta.3",
4
4
  "description": "The @airgap/icp is an ICP implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
5
5
  "keywords": [
6
6
  "airgap",
@@ -17,10 +17,6 @@
17
17
  "publishConfig": {
18
18
  "access": "public"
19
19
  },
20
- "main": "dist/index.js",
21
- "files": [
22
- "dist"
23
- ],
24
20
  "scripts": {
25
21
  "build": "rm -rf ./dist && tsc && node scripts/copy-files-after-build.js",
26
22
  "build-scripts": "tsc scripts/*.ts",
@@ -39,13 +35,13 @@
39
35
  "@airgap/module-kit": "*",
40
36
  "@airgap/serializer": "*",
41
37
  "@stablelib/ed25519": "^1.0.3",
42
- "crc-32": "1.2.2",
43
- "isomorphic-fetch": "^3.0.0",
44
- "secp256k1": "^5.0.0",
45
38
  "base64-arraybuffer": "^1.0.2",
46
39
  "bip39": "^3.0.4",
47
40
  "borc": "^3.0.0",
41
+ "crc-32": "1.2.2",
42
+ "isomorphic-fetch": "^3.0.0",
48
43
  "js-sha256": "^0.9.0",
44
+ "secp256k1": "^5.0.0",
49
45
  "simple-cbor": "^0.4.1"
50
46
  },
51
47
  "nyc": {
@@ -0,0 +1,9 @@
1
+ import { AirGapBlockExplorer, BlockExplorerMetadata } from '@airgap/module-kit';
2
+ export declare class ICPBlockExplorer implements AirGapBlockExplorer {
3
+ readonly url: string;
4
+ constructor(url?: string);
5
+ private readonly metadata;
6
+ getMetadata(): Promise<BlockExplorerMetadata>;
7
+ createAddressUrl(address: string): Promise<string>;
8
+ createTransactionUrl(transactionId: string): Promise<string>;
9
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ICPBlockExplorer = void 0;
40
+ var BLOCK_EXPLORER_URL = 'https://dashboard.internetcomputer.org/';
41
+ var ICPBlockExplorer = /** @class */ (function () {
42
+ function ICPBlockExplorer(url) {
43
+ if (url === void 0) { url = BLOCK_EXPLORER_URL; }
44
+ this.url = url;
45
+ this.metadata = {
46
+ name: 'ICP Explorer',
47
+ url: this.url
48
+ };
49
+ }
50
+ ICPBlockExplorer.prototype.getMetadata = function () {
51
+ return __awaiter(this, void 0, void 0, function () {
52
+ return __generator(this, function (_a) {
53
+ return [2 /*return*/, this.metadata];
54
+ });
55
+ });
56
+ };
57
+ ICPBlockExplorer.prototype.createAddressUrl = function (address) {
58
+ return __awaiter(this, void 0, void 0, function () {
59
+ return __generator(this, function (_a) {
60
+ return [2 /*return*/, "".concat(this.url, "/account/").concat(address)];
61
+ });
62
+ });
63
+ };
64
+ ICPBlockExplorer.prototype.createTransactionUrl = function (transactionId) {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ return __generator(this, function (_a) {
67
+ return [2 /*return*/, "".concat(this.url, "/transaction/").concat(transactionId)];
68
+ });
69
+ });
70
+ };
71
+ return ICPBlockExplorer;
72
+ }());
73
+ exports.ICPBlockExplorer = ICPBlockExplorer;
74
+ //# sourceMappingURL=ICPBlockExplorer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICPBlockExplorer.js","sourceRoot":"","sources":["../../../src/v1/block-explorer/ICPBlockExplorer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAM,kBAAkB,GAAW,yCAAyC,CAAA;AAE5E;IACE,0BAAmC,GAAgC;QAAhC,oBAAA,EAAA,wBAAgC;QAAhC,QAAG,GAAH,GAAG,CAA6B;QAElD,aAAQ,GAA0B;YACjD,IAAI,EAAE,cAAc;YACpB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IALqE,CAAC;IAO1D,sCAAW,GAAxB;;;gBACE,sBAAO,IAAI,CAAC,QAAQ,EAAA;;;KACrB;IAEY,2CAAgB,GAA7B,UAA8B,OAAe;;;gBAC3C,sBAAO,UAAG,IAAI,CAAC,GAAG,sBAAY,OAAO,CAAE,EAAA;;;KACxC;IACY,+CAAoB,GAAjC,UAAkC,aAAqB;;;gBACrD,sBAAO,UAAG,IAAI,CAAC,GAAG,0BAAgB,aAAa,CAAE,EAAA;;;KAClD;IACH,uBAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,4CAAgB"}
package/v1/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { ICPBlockExplorer } from './block-explorer/ICPBlockExplorer';
2
+ import { ICPModule } from './module/ICPModule';
3
+ import { ICPProtocol, createICPProtocol, createICPProtocolOptions } from './protocol/ICPProtocol';
4
+ import { ICPTransactionSignRequest } from './serializer/v3/schemas/definitions/transaction-sign-request-icp';
5
+ import { ICPTransactionSignResponse } from './serializer/v3/schemas/definitions/transaction-sign-response-icp';
6
+ import { ICPCryptoConfiguration } from './types/crypto';
7
+ import { ICPProtocolNetwork, ICPProtocolOptions, ICPUnits } from './types/protocol';
8
+ import { ICPSignedTransaction, ICPUnsignedTransaction } from './types/transaction';
9
+ export { ICPModule };
10
+ export { ICPProtocol, createICPProtocol, createICPProtocolOptions };
11
+ export { ICPBlockExplorer };
12
+ export { ICPCryptoConfiguration, ICPUnits, ICPProtocolOptions, ICPProtocolNetwork, ICPUnsignedTransaction, ICPSignedTransaction };
13
+ export { ICPTransactionSignRequest, ICPTransactionSignResponse };
package/v1/index.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ICPBlockExplorer = exports.createICPProtocolOptions = exports.createICPProtocol = exports.ICPModule = void 0;
4
+ var ICPBlockExplorer_1 = require("./block-explorer/ICPBlockExplorer");
5
+ Object.defineProperty(exports, "ICPBlockExplorer", { enumerable: true, get: function () { return ICPBlockExplorer_1.ICPBlockExplorer; } });
6
+ var ICPModule_1 = require("./module/ICPModule");
7
+ Object.defineProperty(exports, "ICPModule", { enumerable: true, get: function () { return ICPModule_1.ICPModule; } });
8
+ var ICPProtocol_1 = require("./protocol/ICPProtocol");
9
+ Object.defineProperty(exports, "createICPProtocol", { enumerable: true, get: function () { return ICPProtocol_1.createICPProtocol; } });
10
+ Object.defineProperty(exports, "createICPProtocolOptions", { enumerable: true, get: function () { return ICPProtocol_1.createICPProtocolOptions; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,sEAAoE;AAmB3D,iGAnBA,mCAAgB,OAmBA;AAlBzB,gDAA8C;AAUrC,0FAVA,qBAAS,OAUA;AATlB,sDAAiG;AAa3E,kGAbA,+BAAiB,OAaA;AAAE,yGAbA,sCAAwB,OAaA"}
@@ -0,0 +1,15 @@
1
+ import { MainProtocolSymbols } from '@airgap/coinlib-core';
2
+ import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, AirGapV3SerializerCompanion, ProtocolConfiguration } from '@airgap/module-kit';
3
+ declare type SupportedProtocols = MainProtocolSymbols.ICP;
4
+ export declare class ICPModule implements AirGapModule<{
5
+ Protocols: SupportedProtocols;
6
+ }> {
7
+ private readonly networkRegistries;
8
+ readonly supportedProtocols: Record<SupportedProtocols, ProtocolConfiguration>;
9
+ createV3SerializerCompanion(): Promise<AirGapV3SerializerCompanion>;
10
+ createOfflineProtocol(identifier: SupportedProtocols): Promise<AirGapOfflineProtocol | undefined>;
11
+ createOnlineProtocol(identifier: SupportedProtocols, networkId?: string): Promise<AirGapOnlineProtocol | undefined>;
12
+ createBlockExplorer(identifier: SupportedProtocols, networkId?: string): Promise<AirGapBlockExplorer | undefined>;
13
+ private createProtocol;
14
+ }
15
+ export {};
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ICPModule = void 0;
40
+ var coinlib_core_1 = require("@airgap/coinlib-core");
41
+ var errors_1 = require("@airgap/coinlib-core/errors");
42
+ var module_kit_1 = require("@airgap/module-kit");
43
+ var ICPBlockExplorer_1 = require("../block-explorer/ICPBlockExplorer");
44
+ var ICPProtocol_1 = require("../protocol/ICPProtocol");
45
+ var serializer_companion_1 = require("../serializer/v3/serializer-companion");
46
+ var ICPModule = /** @class */ (function () {
47
+ function ICPModule() {
48
+ var _a;
49
+ this.networkRegistries = (_a = {},
50
+ _a[coinlib_core_1.MainProtocolSymbols.ICP] = new module_kit_1.ModuleNetworkRegistry({
51
+ supportedNetworks: [ICPProtocol_1.ICP_MAINNET_PROTOCOL_NETWORK]
52
+ }),
53
+ _a);
54
+ this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
55
+ }
56
+ ICPModule.prototype.createV3SerializerCompanion = function () {
57
+ return __awaiter(this, void 0, void 0, function () {
58
+ return __generator(this, function (_a) {
59
+ return [2 /*return*/, new serializer_companion_1.ICPV3SerializerCompanion()];
60
+ });
61
+ });
62
+ };
63
+ ICPModule.prototype.createOfflineProtocol = function (identifier) {
64
+ return __awaiter(this, void 0, void 0, function () {
65
+ return __generator(this, function (_a) {
66
+ return [2 /*return*/, this.createProtocol(identifier)];
67
+ });
68
+ });
69
+ };
70
+ ICPModule.prototype.createOnlineProtocol = function (identifier, networkId) {
71
+ var _a;
72
+ return __awaiter(this, void 0, void 0, function () {
73
+ var network;
74
+ return __generator(this, function (_b) {
75
+ network = (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkId);
76
+ if (network === undefined) {
77
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ICP, 'Protocol network not supported.');
78
+ }
79
+ return [2 /*return*/, this.createProtocol(identifier, network)];
80
+ });
81
+ });
82
+ };
83
+ ICPModule.prototype.createBlockExplorer = function (identifier, networkId) {
84
+ var _a;
85
+ return __awaiter(this, void 0, void 0, function () {
86
+ var network;
87
+ return __generator(this, function (_b) {
88
+ network = (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkId);
89
+ if ((network === null || network === void 0 ? void 0 : network.type) !== 'mainnet') {
90
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ICP, 'Block Explorer network not supported.');
91
+ }
92
+ return [2 /*return*/, new ICPBlockExplorer_1.ICPBlockExplorer()];
93
+ });
94
+ });
95
+ };
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
+ return ICPModule;
105
+ }());
106
+ exports.ICPModule = ICPModule;
107
+ //# sourceMappingURL=ICPModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICPModule.js","sourceRoot":"","sources":["../../../src/v1/module/ICPModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAkE;AAClE,sDAAqE;AACrE,iDAW2B;AAE3B,uEAAqE;AACrE,uDAAyF;AACzF,8EAAgF;AAIhF;IAAA;;QACmB,sBAAiB;YAChC,GAAC,kCAAmB,CAAC,GAAG,IAAG,IAAI,kCAAqB,CAAC;gBACnD,iBAAiB,EAAE,CAAC,0CAA4B,CAAC;aAClD,CAAC;gBACH;QACe,uBAAkB,GAAsD,IAAA,qCAAwB,EAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IAoC1I,CAAC;IAlCc,+CAA2B,GAAxC;;;gBACE,sBAAO,IAAI,+CAAwB,EAAE,EAAA;;;KACtC;IAEY,yCAAqB,GAAlC,UAAmC,UAA8B;;;gBAC/D,sBAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,EAAA;;;KACvC;IAEY,wCAAoB,GAAjC,UAAkC,UAA8B,EAAE,SAAkB;;;;;gBAC5E,OAAO,GAAgC,MAAA,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,0CAAE,WAAW,CAAC,SAAS,CAAC,CAAA;gBACvG,IAAI,OAAO,KAAK,SAAS,EAAE;oBACzB,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,GAAG,EAAE,iCAAiC,CAAC,CAAA;iBACjF;gBAED,sBAAO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,EAAA;;;KAChD;IAEY,uCAAmB,GAAhC,UAAiC,UAA8B,EAAE,SAAkB;;;;;gBAC3E,OAAO,GAAgC,MAAA,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,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;IAEO,kCAAc,GAAtB,UAAuB,UAA8B,EAAE,OAAyB;QAC9E,QAAQ,UAAU,EAAE;YAClB,KAAK,kCAAmB,CAAC,GAAG;gBAC1B,OAAO,IAAA,+BAAiB,EAAC,EAAE,OAAO,SAAA,EAAE,CAAC,CAAA;YACvC;gBACE,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,GAAG,EAAE,mBAAY,UAAU,oBAAiB,CAAC,CAAA;SACzF;IACH,CAAC;IACH,gBAAC;AAAD,CAAC,AA1CD,IA0CC;AA1CY,8BAAS"}
package/v1/module.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { AirGapModule } from '@airgap/module-kit';
2
+ export * from './index';
3
+ export declare function create(): AirGapModule;
package/v1/module.js ADDED
@@ -0,0 +1,24 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.create = void 0;
18
+ var ICPModule_1 = require("./module/ICPModule");
19
+ __exportStar(require("./index"), exports);
20
+ function create() {
21
+ return new ICPModule_1.ICPModule();
22
+ }
23
+ exports.create = create;
24
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/v1/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,gDAA8C;AAE9C,0CAAuB;AAEvB,SAAgB,MAAM;IACpB,OAAO,IAAI,qBAAS,EAAE,CAAA;AACxB,CAAC;AAFD,wBAEC"}
@@ -0,0 +1,26 @@
1
+ import 'isomorphic-fetch';
2
+ interface Transaction {
3
+ to: string;
4
+ amount: bigint;
5
+ fee: bigint;
6
+ }
7
+ export declare function getKeyPairFromExtendedSecretKey(extendedSecretKey: string): {
8
+ publicKey: string;
9
+ privateKey: string;
10
+ };
11
+ export declare function getAddressFromPublicKey(publicKey: string, subAccount?: Uint8Array): string;
12
+ export declare function createUnsignedTransaction(transaction: Transaction): string;
13
+ export declare function getInfoFromUnsignedTransaction(unsignedTransaction: string): {
14
+ to: string;
15
+ fee: bigint;
16
+ memo: bigint;
17
+ from_subaccount: string[];
18
+ created_at_time: any[];
19
+ amount: bigint;
20
+ };
21
+ export declare function signTransaction(unsignedTransaction: string, privateKey: string): Promise<string>;
22
+ export declare function getInfoFromSignedTransaction(signedTransaction: string): any;
23
+ 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>;
26
+ export {};