@aeternity/aepp-sdk 14.0.0 → 14.1.1

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 (206) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +11 -19
  3. package/dist/aepp-sdk.browser-script.cjs +1 -1
  4. package/dist/aepp-sdk.browser-script.cjs.LICENSE.txt +2 -0
  5. package/dist/aepp-sdk.browser-script.cjs.map +1 -1
  6. package/dist/aepp-sdk.browser.cjs +1 -1
  7. package/dist/aepp-sdk.browser.cjs.map +1 -1
  8. package/dist/aepp-sdk.cjs +10846 -4277
  9. package/dist/aepp-sdk.cjs.map +1 -1
  10. package/es/AeSdkBase.d.ts +10 -1
  11. package/es/AeSdkBase.js +12 -2
  12. package/es/AeSdkBase.js.map +1 -1
  13. package/es/AeSdkMethods.d.ts +1 -1
  14. package/es/AeSdkMethods.js.map +1 -1
  15. package/es/AeSdkWallet.js +1 -1
  16. package/es/AeSdkWallet.js.map +1 -1
  17. package/es/Middleware.d.ts +5 -1
  18. package/es/Middleware.js +7 -2
  19. package/es/Middleware.js.map +1 -1
  20. package/es/MiddlewareSubscriber.d.ts +3 -0
  21. package/es/MiddlewareSubscriber.js +4 -0
  22. package/es/MiddlewareSubscriber.js.map +1 -1
  23. package/es/Node.d.ts +6 -1
  24. package/es/Node.js +28 -4
  25. package/es/Node.js.map +1 -1
  26. package/es/account/Base.d.ts +12 -0
  27. package/es/account/Base.js +1 -0
  28. package/es/account/Base.js.map +1 -1
  29. package/es/account/BaseFactory.d.ts +1 -0
  30. package/es/account/BaseFactory.js +1 -0
  31. package/es/account/BaseFactory.js.map +1 -1
  32. package/es/account/Generalized.d.ts +5 -0
  33. package/es/account/Generalized.js +9 -0
  34. package/es/account/Generalized.js.map +1 -1
  35. package/es/account/Ledger.d.ts +5 -0
  36. package/es/account/Ledger.js +9 -0
  37. package/es/account/Ledger.js.map +1 -1
  38. package/es/account/LedgerFactory.d.ts +2 -0
  39. package/es/account/LedgerFactory.js +10 -4
  40. package/es/account/LedgerFactory.js.map +1 -1
  41. package/es/account/Memory.d.ts +5 -0
  42. package/es/account/Memory.js +14 -5
  43. package/es/account/Memory.js.map +1 -1
  44. package/es/account/Metamask.d.ts +8 -0
  45. package/es/account/Metamask.js +13 -0
  46. package/es/account/Metamask.js.map +1 -1
  47. package/es/account/MetamaskFactory.d.ts +20 -2
  48. package/es/account/MetamaskFactory.js +93 -39
  49. package/es/account/MetamaskFactory.js.map +1 -1
  50. package/es/account/MnemonicFactory.d.ts +12 -2
  51. package/es/account/MnemonicFactory.js +48 -24
  52. package/es/account/MnemonicFactory.js.map +1 -1
  53. package/es/account/Rpc.d.ts +5 -0
  54. package/es/account/Rpc.js +8 -0
  55. package/es/account/Rpc.js.map +1 -1
  56. package/es/aens.d.ts +35 -7
  57. package/es/aens.js +62 -20
  58. package/es/aens.js.map +1 -1
  59. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -1
  60. package/es/aepp-wallet-communication/connection/BrowserRuntime.js.map +1 -1
  61. package/es/apis/middleware/middleware.d.ts +99 -9
  62. package/es/apis/middleware/middleware.js +560 -91
  63. package/es/apis/middleware/middleware.js.map +1 -1
  64. package/es/apis/middleware/models/index.d.ts +1267 -1582
  65. package/es/apis/middleware/models/index.js +1 -1363
  66. package/es/apis/middleware/models/index.js.map +1 -1
  67. package/es/apis/middleware/models/mappers.d.ts +126 -56
  68. package/es/apis/middleware/models/mappers.js +6250 -2989
  69. package/es/apis/middleware/models/mappers.js.map +1 -1
  70. package/es/apis/middleware/models/parameters.d.ts +54 -33
  71. package/es/apis/middleware/models/parameters.js +389 -134
  72. package/es/apis/middleware/models/parameters.js.map +1 -1
  73. package/es/apis/node/models/index.d.ts +60 -15
  74. package/es/apis/node/models/index.js.map +1 -1
  75. package/es/apis/node/models/mappers.d.ts +3 -0
  76. package/es/apis/node/models/mappers.js +130 -2
  77. package/es/apis/node/models/mappers.js.map +1 -1
  78. package/es/apis/node/node.d.ts +13 -1
  79. package/es/apis/node/node.js +54 -0
  80. package/es/apis/node/node.js.map +1 -1
  81. package/es/chain.d.ts +19 -6
  82. package/es/chain.js +30 -24
  83. package/es/chain.js.map +1 -1
  84. package/es/channel/Contract.d.ts +6 -3
  85. package/es/channel/Contract.js +5 -2
  86. package/es/channel/Contract.js.map +1 -1
  87. package/es/channel/Spend.d.ts +1 -1
  88. package/es/channel/Spend.js.map +1 -1
  89. package/es/channel/handlers.js +1 -2
  90. package/es/channel/handlers.js.map +1 -1
  91. package/es/channel/internal.d.ts +1 -1
  92. package/es/channel/internal.js +2 -2
  93. package/es/channel/internal.js.map +1 -1
  94. package/es/contract/Contract.d.ts +13 -2
  95. package/es/contract/Contract.js +22 -12
  96. package/es/contract/Contract.js.map +1 -1
  97. package/es/contract/compiler/Base.d.ts +1 -0
  98. package/es/contract/compiler/Base.js +1 -0
  99. package/es/contract/compiler/Base.js.map +1 -1
  100. package/es/contract/compiler/Cli.d.ts +2 -1
  101. package/es/contract/compiler/Cli.js +17 -11
  102. package/es/contract/compiler/Cli.js.map +1 -1
  103. package/es/contract/compiler/Http.d.ts +2 -1
  104. package/es/contract/compiler/Http.js +3 -2
  105. package/es/contract/compiler/Http.js.map +1 -1
  106. package/es/contract/compiler/getFileSystem.d.ts +1 -0
  107. package/es/contract/compiler/getFileSystem.js +1 -0
  108. package/es/contract/compiler/getFileSystem.js.map +1 -1
  109. package/es/contract/ga.d.ts +3 -3
  110. package/es/contract/ga.js +3 -3
  111. package/es/contract/ga.js.map +1 -1
  112. package/es/index-browser.d.ts +32 -2
  113. package/es/index-browser.js +32 -2
  114. package/es/index-browser.js.map +1 -1
  115. package/es/oracle/Oracle.d.ts +10 -1
  116. package/es/oracle/Oracle.js +16 -6
  117. package/es/oracle/Oracle.js.map +1 -1
  118. package/es/oracle/OracleBase.d.ts +15 -2
  119. package/es/oracle/OracleBase.js +23 -1
  120. package/es/oracle/OracleBase.js.map +1 -1
  121. package/es/oracle/OracleClient.d.ts +3 -0
  122. package/es/oracle/OracleClient.js +6 -1
  123. package/es/oracle/OracleClient.js.map +1 -1
  124. package/es/spend.js +1 -1
  125. package/es/spend.js.map +1 -1
  126. package/es/tx/builder/common.js +6 -3
  127. package/es/tx/builder/common.js.map +1 -1
  128. package/es/tx/builder/constants.d.ts +53 -3
  129. package/es/tx/builder/constants.js +62 -12
  130. package/es/tx/builder/constants.js.map +1 -1
  131. package/es/tx/builder/delegation/schema.js +15 -0
  132. package/es/tx/builder/delegation/schema.js.map +1 -1
  133. package/es/tx/builder/entry/constants.d.ts +4 -1
  134. package/es/tx/builder/entry/constants.js +10 -1
  135. package/es/tx/builder/entry/constants.js.map +1 -1
  136. package/es/tx/builder/entry/index.js +1 -2
  137. package/es/tx/builder/entry/index.js.map +1 -1
  138. package/es/tx/builder/field-types/ct-version.js +1 -2
  139. package/es/tx/builder/field-types/ct-version.js.map +1 -1
  140. package/es/tx/builder/field-types/fee.d.ts +1 -1
  141. package/es/tx/builder/field-types/fee.js +4 -4
  142. package/es/tx/builder/field-types/fee.js.map +1 -1
  143. package/es/tx/builder/field-types/gas-price.d.ts +3 -0
  144. package/es/tx/builder/field-types/gas-price.js +1 -1
  145. package/es/tx/builder/field-types/gas-price.js.map +1 -1
  146. package/es/tx/builder/field-types/name-fee.js +1 -1
  147. package/es/tx/builder/field-types/name-fee.js.map +1 -1
  148. package/es/tx/builder/field-types/name-id.js +2 -2
  149. package/es/tx/builder/field-types/name-id.js.map +1 -1
  150. package/es/tx/builder/field-types/nonce.d.ts +1 -1
  151. package/es/tx/builder/field-types/nonce.js.map +1 -1
  152. package/es/tx/builder/field-types/pointers.js +3 -3
  153. package/es/tx/builder/field-types/pointers.js.map +1 -1
  154. package/es/tx/builder/field-types/ttl.d.ts +1 -2
  155. package/es/tx/builder/field-types/ttl.js +7 -5
  156. package/es/tx/builder/field-types/ttl.js.map +1 -1
  157. package/es/tx/builder/helpers.d.ts +18 -12
  158. package/es/tx/builder/helpers.js +25 -17
  159. package/es/tx/builder/helpers.js.map +1 -1
  160. package/es/tx/builder/schema.d.ts +50 -70
  161. package/es/tx/builder/schema.generated.d.ts +12 -12
  162. package/es/tx/builder/schema.generated.js.map +1 -1
  163. package/es/tx/builder/schema.js +5 -3
  164. package/es/tx/builder/schema.js.map +1 -1
  165. package/es/tx/execution-cost.d.ts +3 -0
  166. package/es/tx/execution-cost.js +7 -4
  167. package/es/tx/execution-cost.js.map +1 -1
  168. package/es/tx/transaction-signer.d.ts +1 -0
  169. package/es/tx/transaction-signer.js +1 -0
  170. package/es/tx/transaction-signer.js.map +1 -1
  171. package/es/tx/validator.js +4 -3
  172. package/es/tx/validator.js.map +1 -1
  173. package/es/utils/MiddlewarePage.d.ts +4 -3
  174. package/es/utils/MiddlewarePage.js.map +1 -1
  175. package/es/utils/amount-formatter.d.ts +15 -1
  176. package/es/utils/amount-formatter.js +17 -1
  177. package/es/utils/amount-formatter.js.map +1 -1
  178. package/es/utils/autorest.d.ts +1 -1
  179. package/es/utils/autorest.js +10 -4
  180. package/es/utils/autorest.js.map +1 -1
  181. package/es/utils/bignumber.d.ts +1 -1
  182. package/es/utils/bignumber.js +1 -1
  183. package/es/utils/bignumber.js.map +1 -1
  184. package/es/utils/bytes.d.ts +3 -1
  185. package/es/utils/bytes.js +3 -1
  186. package/es/utils/bytes.js.map +1 -1
  187. package/es/utils/crypto.d.ts +48 -15
  188. package/es/utils/crypto.js +80 -29
  189. package/es/utils/crypto.js.map +1 -1
  190. package/es/utils/encoder-types.d.ts +1 -1
  191. package/es/utils/encoder-types.js +1 -1
  192. package/es/utils/encoder-types.js.map +1 -1
  193. package/es/utils/encoder.d.ts +2 -0
  194. package/es/utils/encoder.js +2 -0
  195. package/es/utils/encoder.js.map +1 -1
  196. package/es/utils/errors.d.ts +2 -2
  197. package/es/utils/errors.js +2 -2
  198. package/es/utils/errors.js.map +1 -1
  199. package/es/utils/json-big.js +1 -1
  200. package/es/utils/json-big.js.map +1 -1
  201. package/es/utils/jwt.js +3 -3
  202. package/es/utils/jwt.js.map +1 -1
  203. package/es/utils/typed-data.d.ts +5 -0
  204. package/es/utils/typed-data.js +6 -0
  205. package/es/utils/typed-data.js.map +1 -1
  206. package/package.json +51 -52
@@ -3,20 +3,22 @@ import nacl from 'tweetnacl';
3
3
  // js extension is required for mjs build, not importing the whole package to reduce bundle size
4
4
  // eslint-disable-next-line import/extensions
5
5
  import { blake2b } from 'blakejs/blake2b.js';
6
- import { encode as varuintEncode } from 'varuint-bitcoin';
7
6
  import { concatBuffers, isItemOfArray } from './other.js';
8
- import { decode, encode, Encoding } from './encoder.js';
7
+ import { decode, Encoding } from './encoder.js';
9
8
  import { ArgumentError } from './errors.js';
10
9
 
11
10
  /**
12
11
  * Check if address is valid
13
12
  * @param maybeAddress - Address to check
13
+ * @category utils
14
+ * @deprecated Use {@link isEncoded} instead
14
15
  */
15
16
 
16
17
  /**
17
18
  * Check if data is encoded in one of provided encodings
18
19
  * @param maybeEncoded - Data to check
19
20
  * @param encodings - Rest parameters with encodings to check against
21
+ * @deprecated Use {@link isEncoded} instead
20
22
  */
21
23
 
22
24
  export function isAddressValid(maybeEncoded, ...encodings) {
@@ -33,9 +35,51 @@ export function isAddressValid(maybeEncoded, ...encodings) {
33
35
  }
34
36
  }
35
37
 
38
+ /**
39
+ * Check if data is encoded in any encoding
40
+ * @param maybeEncoded - Data to check
41
+ * @category utils
42
+ */
43
+
44
+ /**
45
+ * Check if data is encoded in one of provided encodings
46
+ * @param maybeEncoded - Data to check
47
+ * @param encodings - Rest parameters with encodings to check against
48
+ */
49
+
50
+ export function ensureEncoded(maybeEncoded, ...encodings) {
51
+ decode(maybeEncoded);
52
+ if (encodings.length === 0) return;
53
+ const encoding = maybeEncoded.split('_')[0];
54
+ if (isItemOfArray(encoding, encodings)) return;
55
+ throw new ArgumentError('Encoded string type', encodings.length > 1 ? `one of ${encodings.join(', ')}` : encodings[0], encoding);
56
+ }
57
+
58
+ /**
59
+ * Check if data is encoded in any encoding
60
+ * @param maybeEncoded - Data to check
61
+ * @category utils
62
+ */
63
+
64
+ /**
65
+ * Check if data is encoded in one of provided encodings
66
+ * @param maybeEncoded - Data to check
67
+ * @param encodings - Rest parameters with encodings to check against
68
+ */
69
+
70
+ export function isEncoded(maybeEncoded, ...encodings) {
71
+ try {
72
+ ensureEncoded(maybeEncoded, ...encodings);
73
+ return true;
74
+ } catch (error) {
75
+ return false;
76
+ }
77
+ }
78
+
36
79
  /**
37
80
  * Generate a random salt (positive integer)
38
81
  * @returns random salt
82
+ * @category utils
39
83
  */
40
84
  export function genSalt() {
41
85
  const [random] = new BigUint64Array(nacl.randomBytes(8).buffer);
@@ -47,53 +91,61 @@ export function genSalt() {
47
91
  * representation in a binary digit representation
48
92
  * @param value - Value to encode
49
93
  * @returns Encoded number
94
+ * @category utils
95
+ * @deprecated This function is out of the sdk scope. Copy implementation from sdk if necessary.
50
96
  */
51
97
  export function encodeUnsigned(value) {
52
98
  const binary = _Buffer.allocUnsafe(4);
53
99
  binary.writeUInt32BE(value);
54
- return binary.slice(binary.findIndex(i => i !== 0));
100
+ return binary.subarray(binary.findIndex(i => i !== 0));
55
101
  }
56
102
 
57
103
  /**
58
104
  * Calculate 256bits Blake2b hash of `input`
59
105
  * @param input - Data to hash
60
106
  * @returns Hash
107
+ * @category utils
108
+ * @deprecated use "blakejs" package directly
61
109
  */
62
110
  export function hash(input) {
63
111
  return _Buffer.from(blake2b(input, undefined, 32)); // 256 bits
64
112
  }
65
113
 
66
- // Todo Duplicated in tx builder. remove
67
- /**
68
- * Compute contract address
69
- * @category contract
70
- * @param owner - Address of contract owner
71
- * @param nonce - Round when contract was created
72
- * @returns Contract address
73
- */
74
- export function encodeContractAddress(owner, nonce) {
75
- const publicKey = decode(owner);
76
- const binary = concatBuffers([publicKey, encodeUnsigned(nonce)]);
77
- return encode(hash(binary), Encoding.ContractAddress);
78
- }
79
-
80
114
  /**
81
- * Verify that signature was signed by public key
115
+ * Verify that data was signed by account
82
116
  * @param data - Data that was signed
83
117
  * @param signature - Signature of data
84
- * @param address - Address to verify against
85
- * @returns is data was signed by address
118
+ * @param address - Address of account to verify against
119
+ * @returns is data was signed by account
120
+ * @category utils
86
121
  */
87
- export function verify(data, signature, address) {
122
+ export function verifySignature(data, signature, address) {
88
123
  return nacl.sign.detached.verify(data, signature, decode(address));
89
124
  }
125
+ export function encodeVarUInt(value) {
126
+ if (value < 0xfd) {
127
+ return _Buffer.from([value]);
128
+ }
129
+ if (value <= 0xffff) {
130
+ return concatBuffers([_Buffer.from([0xfd]), _Buffer.from(new Uint16Array([value]).buffer)]);
131
+ }
132
+ if (value <= 0xffffffff) {
133
+ return concatBuffers([_Buffer.from([0xfe]), _Buffer.from(new Uint32Array([value]).buffer)]);
134
+ }
135
+ return concatBuffers([_Buffer.from([0xff]), _Buffer.from(new BigUint64Array([BigInt(value)]).buffer)]);
136
+ }
90
137
  const messagePrefix = _Buffer.from('aeternity Signed Message:\n', 'utf8');
91
- export const messagePrefixLength = varuintEncode(messagePrefix.length).buffer;
138
+ export const messagePrefixLength = encodeVarUInt(messagePrefix.length);
92
139
 
93
- // TODO: consider rename to hashMessage
94
- export function messageToHash(message) {
140
+ /**
141
+ * Hash message
142
+ * @param message - Message to hash
143
+ * @returns Hash of message
144
+ * @category utils
145
+ */
146
+ export function hashMessage(message) {
95
147
  const msg = _Buffer.from(message, 'utf8');
96
- return hash(concatBuffers([messagePrefixLength, messagePrefix, varuintEncode(msg.length).buffer, msg]));
148
+ return hash(concatBuffers([messagePrefixLength, messagePrefix, encodeVarUInt(msg.length), msg]));
97
149
  }
98
150
 
99
151
  /**
@@ -102,10 +154,9 @@ export function messageToHash(message) {
102
154
  * @param signature - Signature of message
103
155
  * @param address - Address to verify against
104
156
  * @returns is data was signed by address
157
+ * @category utils
105
158
  */
106
- // TODO: deprecate in favour of `verify(messageToHash(message), ...`, also the name is confusing
107
- // it should contain "signature"
108
- export function verifyMessage(message, signature, address) {
109
- return verify(messageToHash(message), signature, address);
159
+ export function verifyMessageSignature(message, signature, address) {
160
+ return verifySignature(hashMessage(message), signature, address);
110
161
  }
111
162
  //# sourceMappingURL=crypto.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.js","names":["nacl","blake2b","encode","varuintEncode","concatBuffers","isItemOfArray","decode","Encoding","ArgumentError","isAddressValid","maybeEncoded","encodings","length","AccountAddress","encoding","split","join","error","genSalt","random","BigUint64Array","randomBytes","buffer","Number","BigInt","MAX_SAFE_INTEGER","encodeUnsigned","value","binary","_Buffer","allocUnsafe","writeUInt32BE","slice","findIndex","i","hash","input","from","undefined","encodeContractAddress","owner","nonce","publicKey","ContractAddress","verify","data","signature","address","sign","detached","messagePrefix","messagePrefixLength","messageToHash","message","msg","verifyMessage"],"sources":["../../src/utils/crypto.ts"],"sourcesContent":["import nacl from 'tweetnacl';\n// js extension is required for mjs build, not importing the whole package to reduce bundle size\n// eslint-disable-next-line import/extensions\nimport { blake2b } from 'blakejs/blake2b.js';\nimport { encode as varuintEncode } from 'varuint-bitcoin';\n\nimport { concatBuffers, isItemOfArray } from './other.js';\nimport { decode, encode, Encoded, Encoding } from './encoder.js';\nimport { ArgumentError } from './errors.js';\n\n/**\n * Check if address is valid\n * @param maybeAddress - Address to check\n */\nexport function isAddressValid(maybeAddress: string): maybeAddress is Encoded.AccountAddress;\n/**\n * Check if data is encoded in one of provided encodings\n * @param maybeEncoded - Data to check\n * @param encodings - Rest parameters with encodings to check against\n */\nexport function isAddressValid<E extends Encoding>(\n maybeEncoded: string,\n ...encodings: E[]\n): maybeEncoded is Encoded.Generic<E>;\nexport function isAddressValid(maybeEncoded: string, ...encodings: Encoding[]): boolean {\n if (encodings.length === 0) encodings = [Encoding.AccountAddress];\n try {\n decode(maybeEncoded as Encoded.Any);\n const encoding = maybeEncoded.split('_')[0];\n if (!isItemOfArray(encoding, encodings)) {\n throw new ArgumentError(\n 'Encoded string type',\n encodings.length > 1 ? `one of ${encodings.join(', ')}` : encodings[0],\n encoding,\n );\n }\n return true;\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Generate a random salt (positive integer)\n * @returns random salt\n */\nexport function genSalt(): number {\n const [random] = new BigUint64Array(nacl.randomBytes(8).buffer);\n return Number(random % BigInt(Number.MAX_SAFE_INTEGER));\n}\n\n/**\n * Converts a positive integer to the smallest possible\n * representation in a binary digit representation\n * @param value - Value to encode\n * @returns Encoded number\n */\nexport function encodeUnsigned(value: number): Buffer {\n const binary = Buffer.allocUnsafe(4);\n binary.writeUInt32BE(value);\n return binary.slice(binary.findIndex((i) => i !== 0));\n}\n\n/**\n * Calculate 256bits Blake2b hash of `input`\n * @param input - Data to hash\n * @returns Hash\n */\nexport function hash(input: string | Uint8Array): Buffer {\n return Buffer.from(blake2b(input, undefined, 32)); // 256 bits\n}\n\n// Todo Duplicated in tx builder. remove\n/**\n * Compute contract address\n * @category contract\n * @param owner - Address of contract owner\n * @param nonce - Round when contract was created\n * @returns Contract address\n */\nexport function encodeContractAddress(\n owner: Encoded.AccountAddress,\n nonce: number,\n): Encoded.ContractAddress {\n const publicKey = decode(owner);\n const binary = concatBuffers([publicKey, encodeUnsigned(nonce)]);\n return encode(hash(binary), Encoding.ContractAddress);\n}\n\n/**\n * Verify that signature was signed by public key\n * @param data - Data that was signed\n * @param signature - Signature of data\n * @param address - Address to verify against\n * @returns is data was signed by address\n */\nexport function verify(\n data: Uint8Array,\n signature: Uint8Array,\n address: Encoded.AccountAddress,\n): boolean {\n return nacl.sign.detached.verify(data, signature, decode(address));\n}\n\nconst messagePrefix = Buffer.from('aeternity Signed Message:\\n', 'utf8');\nexport const messagePrefixLength = varuintEncode(messagePrefix.length).buffer;\n\n// TODO: consider rename to hashMessage\nexport function messageToHash(message: string): Buffer {\n const msg = Buffer.from(message, 'utf8');\n return hash(\n concatBuffers([messagePrefixLength, messagePrefix, varuintEncode(msg.length).buffer, msg]),\n );\n}\n\n/**\n * Verify that message was signed by address\n * @param message - Message that was signed\n * @param signature - Signature of message\n * @param address - Address to verify against\n * @returns is data was signed by address\n */\n// TODO: deprecate in favour of `verify(messageToHash(message), ...`, also the name is confusing\n// it should contain \"signature\"\nexport function verifyMessage(\n message: string,\n signature: Uint8Array,\n address: Encoded.AccountAddress,\n): boolean {\n return verify(messageToHash(message), signature, address);\n}\n"],"mappings":";AAAA,OAAOA,IAAI,MAAM,WAAW;AAC5B;AACA;AACA,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,MAAM,IAAIC,aAAa,QAAQ,iBAAiB;AAEzD,SAASC,aAAa,EAAEC,aAAa,QAAQ,YAAY;AACzD,SAASC,MAAM,EAAEJ,MAAM,EAAWK,QAAQ,QAAQ,cAAc;AAChE,SAASC,aAAa,QAAQ,aAAa;;AAE3C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAKA,OAAO,SAASC,cAAcA,CAACC,YAAoB,EAAE,GAAGC,SAAqB,EAAW;EACtF,IAAIA,SAAS,CAACC,MAAM,KAAK,CAAC,EAAED,SAAS,GAAG,CAACJ,QAAQ,CAACM,cAAc,CAAC;EACjE,IAAI;IACFP,MAAM,CAACI,YAA2B,CAAC;IACnC,MAAMI,QAAQ,GAAGJ,YAAY,CAACK,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAACV,aAAa,CAACS,QAAQ,EAAEH,SAAS,CAAC,EAAE;MACvC,MAAM,IAAIH,aAAa,CACrB,qBAAqB,EACrBG,SAAS,CAACC,MAAM,GAAG,CAAC,GAAG,UAAUD,SAAS,CAACK,IAAI,CAAC,IAAI,CAAC,EAAE,GAAGL,SAAS,CAAC,CAAC,CAAC,EACtEG,QACF,CAAC;IACH;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOG,KAAK,EAAE;IACd,OAAO,KAAK;EACd;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAAA,EAAW;EAChC,MAAM,CAACC,MAAM,CAAC,GAAG,IAAIC,cAAc,CAACpB,IAAI,CAACqB,WAAW,CAAC,CAA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AC,6BAA6B,EAAE,MAAM,CAAC;AACxE,OAAO,MAAMc,mBAAmB,GAAGhD,aAAa,CAAC+C,aAAa,CAACtC,MAAM,CAAC,CAACU,MAAM;;AAE7E;AACA,OAAO,SAAS8B,aAAaA,CAACC,OAAe,EAAU;EACrD,MAAMC,GAAG,GAAGzB,OAAA,CAAOQ,IAAI,CAACgB,OAAO,EAAE,MAAM,CAAC;EACxC,OAAOlB,IAAI,CACT/B,aAAa,CAAC,CAAC+C,mBAAmB,EAAED,aAAa,EAAE/C,aAAa,CAACmD,GAAG,CAAC1C,MAAM,CAAC,CAACU,MAAM,EAAEgC,GAAG,CAAC,CAC3F,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3BF,OAAe,EACfP,SAAqB,EACrBC,OAA+B,EACtB;EACT,OAAOH,MAAM,CAACQ,aAAa,CAACC,OAAO,CAAC,EAAEP,SAAS,EAAEC,OAAO,CAAC;AAC3D","ignoreList":[]}
1
+ {"version":3,"file":"crypto.js","names":["nacl","blake2b","concatBuffers","isItemOfArray","decode","Encoding","ArgumentError","isAddressValid","maybeEncoded","encodings","length","AccountAddress","encoding","split","join","error","ensureEncoded","isEncoded","genSalt","random","BigUint64Array","randomBytes","buffer","Number","BigInt","MAX_SAFE_INTEGER","encodeUnsigned","value","binary","_Buffer","allocUnsafe","writeUInt32BE","subarray","findIndex","i","hash","input","from","undefined","verifySignature","data","signature","address","sign","detached","verify","encodeVarUInt","Uint16Array","Uint32Array","messagePrefix","messagePrefixLength","hashMessage","message","msg","verifyMessageSignature"],"sources":["../../src/utils/crypto.ts"],"sourcesContent":["import nacl from 'tweetnacl';\n// js extension is required for mjs build, not importing the whole package to reduce bundle size\n// eslint-disable-next-line import/extensions\nimport { blake2b } from 'blakejs/blake2b.js';\n\nimport { concatBuffers, isItemOfArray } from './other.js';\nimport { decode, Encoded, Encoding } from './encoder.js';\nimport { ArgumentError } from './errors.js';\n\n/**\n * Check if address is valid\n * @param maybeAddress - Address to check\n * @category utils\n * @deprecated Use {@link isEncoded} instead\n */\nexport function isAddressValid(maybeAddress: string): maybeAddress is Encoded.AccountAddress;\n/**\n * Check if data is encoded in one of provided encodings\n * @param maybeEncoded - Data to check\n * @param encodings - Rest parameters with encodings to check against\n * @deprecated Use {@link isEncoded} instead\n */\nexport function isAddressValid<E extends Encoding>(\n maybeEncoded: string,\n ...encodings: E[]\n): maybeEncoded is Encoded.Generic<E>;\nexport function isAddressValid(maybeEncoded: string, ...encodings: Encoding[]): boolean {\n if (encodings.length === 0) encodings = [Encoding.AccountAddress];\n try {\n decode(maybeEncoded as Encoded.Any);\n const encoding = maybeEncoded.split('_')[0];\n if (!isItemOfArray(encoding, encodings)) {\n throw new ArgumentError(\n 'Encoded string type',\n encodings.length > 1 ? `one of ${encodings.join(', ')}` : encodings[0],\n encoding,\n );\n }\n return true;\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Check if data is encoded in any encoding\n * @param maybeEncoded - Data to check\n * @category utils\n */\nexport function ensureEncoded(maybeEncoded: string): asserts maybeEncoded is Encoded.Any;\n/**\n * Check if data is encoded in one of provided encodings\n * @param maybeEncoded - Data to check\n * @param encodings - Rest parameters with encodings to check against\n */\nexport function ensureEncoded<E extends Encoding>(\n maybeEncoded: string,\n ...encodings: E[]\n): asserts maybeEncoded is Encoded.Generic<E>;\nexport function ensureEncoded(maybeEncoded: string, ...encodings: Encoding[]): void {\n decode(maybeEncoded as Encoded.Any);\n if (encodings.length === 0) return;\n const encoding = maybeEncoded.split('_')[0];\n if (isItemOfArray(encoding, encodings)) return;\n throw new ArgumentError(\n 'Encoded string type',\n encodings.length > 1 ? `one of ${encodings.join(', ')}` : encodings[0],\n encoding,\n );\n}\n\n/**\n * Check if data is encoded in any encoding\n * @param maybeEncoded - Data to check\n * @category utils\n */\nexport function isEncoded(maybeEncoded: string): maybeEncoded is Encoded.Any;\n/**\n * Check if data is encoded in one of provided encodings\n * @param maybeEncoded - Data to check\n * @param encodings - Rest parameters with encodings to check against\n */\nexport function isEncoded<E extends Encoding>(\n maybeEncoded: string,\n ...encodings: E[]\n): maybeEncoded is Encoded.Generic<E>;\nexport function isEncoded(maybeEncoded: string, ...encodings: Encoding[]): boolean {\n try {\n ensureEncoded(maybeEncoded, ...encodings);\n return true;\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Generate a random salt (positive integer)\n * @returns random salt\n * @category utils\n */\nexport function genSalt(): number {\n const [random] = new BigUint64Array(nacl.randomBytes(8).buffer);\n return Number(random % BigInt(Number.MAX_SAFE_INTEGER));\n}\n\n/**\n * Converts a positive integer to the smallest possible\n * representation in a binary digit representation\n * @param value - Value to encode\n * @returns Encoded number\n * @category utils\n * @deprecated This function is out of the sdk scope. Copy implementation from sdk if necessary.\n */\nexport function encodeUnsigned(value: number): Buffer {\n const binary = Buffer.allocUnsafe(4);\n binary.writeUInt32BE(value);\n return binary.subarray(binary.findIndex((i) => i !== 0));\n}\n\n/**\n * Calculate 256bits Blake2b hash of `input`\n * @param input - Data to hash\n * @returns Hash\n * @category utils\n * @deprecated use \"blakejs\" package directly\n */\nexport function hash(input: string | Uint8Array): Buffer {\n return Buffer.from(blake2b(input, undefined, 32)); // 256 bits\n}\n\n/**\n * Verify that data was signed by account\n * @param data - Data that was signed\n * @param signature - Signature of data\n * @param address - Address of account to verify against\n * @returns is data was signed by account\n * @category utils\n */\nexport function verifySignature(\n data: Uint8Array,\n signature: Uint8Array,\n address: Encoded.AccountAddress,\n): boolean {\n return nacl.sign.detached.verify(data, signature, decode(address));\n}\n\nexport function encodeVarUInt(value: number): Buffer {\n if (value < 0xfd) {\n return Buffer.from([value]);\n }\n if (value <= 0xffff) {\n return concatBuffers([Buffer.from([0xfd]), Buffer.from(new Uint16Array([value]).buffer)]);\n }\n if (value <= 0xffffffff) {\n return concatBuffers([Buffer.from([0xfe]), Buffer.from(new Uint32Array([value]).buffer)]);\n }\n return concatBuffers([\n Buffer.from([0xff]),\n Buffer.from(new BigUint64Array([BigInt(value)]).buffer),\n ]);\n}\n\nconst messagePrefix = Buffer.from('aeternity Signed Message:\\n', 'utf8');\nexport const messagePrefixLength = encodeVarUInt(messagePrefix.length);\n\n/**\n * Hash message\n * @param message - Message to hash\n * @returns Hash of message\n * @category utils\n */\nexport function hashMessage(message: string): Buffer {\n const msg = Buffer.from(message, 'utf8');\n return hash(concatBuffers([messagePrefixLength, messagePrefix, encodeVarUInt(msg.length), msg]));\n}\n\n/**\n * Verify that message was signed by address\n * @param message - Message that was signed\n * @param signature - Signature of message\n * @param address - Address to verify against\n * @returns is data was signed by address\n * @category utils\n */\nexport function verifyMessageSignature(\n message: string,\n signature: Uint8Array,\n address: Encoded.AccountAddress,\n): boolean {\n return verifySignature(hashMessage(message), signature, address);\n}\n"],"mappings":";AAAA,OAAOA,IAAI,MAAM,WAAW;AAC5B;AACA;AACA,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,aAAa,EAAEC,aAAa,QAAQ,YAAY;AACzD,SAASC,MAAM,EAAWC,QAAQ,QAAQ,cAAc;AACxD,SAASC,aAAa,QAAQ,aAAa;;AAE3C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,SAASC,cAAcA,CAACC,YAAoB,EAAE,GAAGC,SAAqB,EAAW;EACtF,IAAIA,SAAS,CAACC,MAAM,KAAK,CAAC,EAAED,SAAS,GAAG,CAACJ,QAAQ,CAACM,cAAc,CAAC;EACjE,IAAI;IACFP,MAAM,CAACI,YAA2B,CAAC;IACnC,MAAMI,QAAQ,GAAGJ,YAAY,CAACK,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAACV,aAAa,CAACS,QAAQ,EAAEH,SAAS,CAAC,EAAE;MACvC,MAAM,IAAIH,aAAa,CACrB,qBAAqB,EACrBG,SAAS,CAACC,MAAM,GAAG,CAAC,GAAG,UAAUD,SAAS,CAACK,IAAI,CAAC,IAAI,C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OAAA,CAAOQ,IAAI,CAAC,IAAIW,WAAW,CAAC,CAACrB,KAAK,CAAC,CAAC,CAACL,MAAM,CAAC,CAAC,CAAC;EAC3F;EACA,OAAOpB,aAAa,CAAC,CACnB2B,OAAA,CAAOQ,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EACnBR,OAAA,CAAOQ,IAAI,CAAC,IAAIjB,cAAc,CAAC,CAACI,MAAM,CAACG,KAAK,CAAC,CAAC,CAAC,CAACL,MAAM,CAAC,CACxD,CAAC;AACJ;AAEA,MAAM2B,aAAa,GAAGpB,OAAA,CAAOQ,IAAI,CAAC,6BAA6B,EAAE,MAAM,CAAC;AACxE,OAAO,MAAMa,mBAAmB,GAAGJ,aAAa,CAACG,aAAa,CAACvC,MAAM,CAAC;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASyC,WAAWA,CAACC,OAAe,EAAU;EACnD,MAAMC,GAAG,GAAGxB,OAAA,CAAOQ,IAAI,CAACe,OAAO,EAAE,MAAM,CAAC;EACxC,OAAOjB,IAAI,CAACjC,aAAa,CAAC,CAACgD,mBAAmB,EAAED,aAAa,EAAEH,aAAa,CAACO,GAAG,CAAC3C,MAAM,CAAC,EAAE2C,GAAG,CAAC,CAAC,CAAC;AAClG;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCF,OAAe,EACfX,SAAqB,EACrBC,OAA+B,EACtB;EACT,OAAOH,eAAe,CAACY,WAAW,CAACC,OAAO,CAAC,EAAEX,SAAS,EAAEC,OAAO,CAAC;AAClE","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @category transaction builder
2
+ * @category utils
3
3
  * @see {@link https://github.com/aeternity/protocol/blob/master/node/api/api_encoding.md}
4
4
  * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L205-L230}
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @category transaction builder
2
+ * @category utils
3
3
  * @see {@link https://github.com/aeternity/protocol/blob/master/node/api/api_encoding.md}
4
4
  * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L205-L230}
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"encoder-types.js","names":["Encoding"],"sources":["../../src/utils/encoder-types.ts"],"sourcesContent":["/**\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/master/node/api/api_encoding.md}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L205-L230}\n */\nexport enum Encoding {\n KeyBlockHash = 'kh',\n MicroBlockHash = 'mh',\n BlockPofHash = 'bf',\n BlockTxHash = 'bx',\n BlockStateHash = 'bs',\n Channel = 'ch',\n ContractAddress = 'ct',\n ContractBytearray = 'cb',\n ContractStoreKey = 'ck',\n ContractStoreValue = 'cv',\n Transaction = 'tx',\n TxHash = 'th',\n OracleAddress = 'ok',\n OracleQuery = 'ov',\n OracleQueryId = 'oq',\n OracleResponse = 'or',\n AccountAddress = 'ak',\n AccountSecretKey = 'sk',\n Signature = 'sg',\n Commitment = 'cm',\n PeerPubkey = 'pp',\n Name = 'nm',\n State = 'st',\n Poi = 'pi',\n StateTrees = 'ss',\n CallStateTree = 'cs',\n Bytearray = 'ba',\n}\n\nexport type KeyBlockHash = `${Encoding.KeyBlockHash}_${string}`;\nexport type MicroBlockHash = `${Encoding.MicroBlockHash}_${string}`;\nexport type BlockPofHash = `${Encoding.BlockPofHash}_${string}`;\nexport type BlockTxHash = `${Encoding.BlockTxHash}_${string}`;\nexport type BlockStateHash = `${Encoding.BlockStateHash}_${string}`;\nexport type Channel = `${Encoding.Channel}_${string}`;\nexport type ContractAddress = `${Encoding.ContractAddress}_${string}`;\nexport type ContractBytearray = `${Encoding.ContractBytearray}_${string}`;\nexport type ContractStoreKey = `${Encoding.ContractStoreKey}_${string}`;\nexport type ContractStoreValue = `${Encoding.ContractStoreValue}_${string}`;\nexport type Transaction = `${Encoding.Transaction}_${string}`;\nexport type TxHash = `${Encoding.TxHash}_${string}`;\nexport type OracleAddress = `${Encoding.OracleAddress}_${string}`;\nexport type OracleQuery = `${Encoding.OracleQuery}_${string}`;\nexport type OracleQueryId = `${Encoding.OracleQueryId}_${string}`;\nexport type OracleResponse = `${Encoding.OracleResponse}_${string}`;\nexport type AccountAddress = `${Encoding.AccountAddress}_${string}`;\nexport type AccountSecretKey = `${Encoding.AccountSecretKey}_${string}`;\nexport type Signature = `${Encoding.Signature}_${string}`;\nexport type Commitment = `${Encoding.Commitment}_${string}`;\nexport type PeerPubkey = `${Encoding.PeerPubkey}_${string}`;\nexport type Name = `${Encoding.Name}_${string}`;\nexport type State = `${Encoding.State}_${string}`;\nexport type Poi = `${Encoding.Poi}_${string}`;\nexport type StateTrees = `${Encoding.StateTrees}_${string}`;\nexport type CallStateTree = `${Encoding.CallStateTree}_${string}`;\nexport type Bytearray = `${Encoding.Bytearray}_${string}`;\n\nexport type Generic<Type extends Encoding> = `${Type}_${string}`;\nexport type Any = `${Encoding}_${string}`;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,WAAYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"encoder-types.js","names":["Encoding"],"sources":["../../src/utils/encoder-types.ts"],"sourcesContent":["/**\n * @category utils\n * @see {@link https://github.com/aeternity/protocol/blob/master/node/api/api_encoding.md}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L205-L230}\n */\nexport enum Encoding {\n KeyBlockHash = 'kh',\n MicroBlockHash = 'mh',\n BlockPofHash = 'bf',\n BlockTxHash = 'bx',\n BlockStateHash = 'bs',\n Channel = 'ch',\n ContractAddress = 'ct',\n ContractBytearray = 'cb',\n ContractStoreKey = 'ck',\n ContractStoreValue = 'cv',\n Transaction = 'tx',\n TxHash = 'th',\n OracleAddress = 'ok',\n OracleQuery = 'ov',\n OracleQueryId = 'oq',\n OracleResponse = 'or',\n AccountAddress = 'ak',\n AccountSecretKey = 'sk',\n Signature = 'sg',\n Commitment = 'cm',\n PeerPubkey = 'pp',\n Name = 'nm',\n State = 'st',\n Poi = 'pi',\n StateTrees = 'ss',\n CallStateTree = 'cs',\n Bytearray = 'ba',\n}\n\nexport type KeyBlockHash = `${Encoding.KeyBlockHash}_${string}`;\nexport type MicroBlockHash = `${Encoding.MicroBlockHash}_${string}`;\nexport type BlockPofHash = `${Encoding.BlockPofHash}_${string}`;\nexport type BlockTxHash = `${Encoding.BlockTxHash}_${string}`;\nexport type BlockStateHash = `${Encoding.BlockStateHash}_${string}`;\nexport type Channel = `${Encoding.Channel}_${string}`;\nexport type ContractAddress = `${Encoding.ContractAddress}_${string}`;\nexport type ContractBytearray = `${Encoding.ContractBytearray}_${string}`;\nexport type ContractStoreKey = `${Encoding.ContractStoreKey}_${string}`;\nexport type ContractStoreValue = `${Encoding.ContractStoreValue}_${string}`;\nexport type Transaction = `${Encoding.Transaction}_${string}`;\nexport type TxHash = `${Encoding.TxHash}_${string}`;\nexport type OracleAddress = `${Encoding.OracleAddress}_${string}`;\nexport type OracleQuery = `${Encoding.OracleQuery}_${string}`;\nexport type OracleQueryId = `${Encoding.OracleQueryId}_${string}`;\nexport type OracleResponse = `${Encoding.OracleResponse}_${string}`;\nexport type AccountAddress = `${Encoding.AccountAddress}_${string}`;\nexport type AccountSecretKey = `${Encoding.AccountSecretKey}_${string}`;\nexport type Signature = `${Encoding.Signature}_${string}`;\nexport type Commitment = `${Encoding.Commitment}_${string}`;\nexport type PeerPubkey = `${Encoding.PeerPubkey}_${string}`;\nexport type Name = `${Encoding.Name}_${string}`;\nexport type State = `${Encoding.State}_${string}`;\nexport type Poi = `${Encoding.Poi}_${string}`;\nexport type StateTrees = `${Encoding.StateTrees}_${string}`;\nexport type CallStateTree = `${Encoding.CallStateTree}_${string}`;\nexport type Bytearray = `${Encoding.Bytearray}_${string}`;\n\nexport type Generic<Type extends Encoding> = `${Type}_${string}`;\nexport type Any = `${Encoding}_${string}`;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,WAAYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}
@@ -12,6 +12,7 @@ export declare function sha256hash(input: Uint8Array | string): Buffer;
12
12
  * @param data - An Base58/64check encoded and prefixed string
13
13
  * (ex tx_..., sg_..., ak_....)
14
14
  * @returns Decoded data
15
+ * @category utils
15
16
  */
16
17
  export declare function decode(data: Encoded.Any): Buffer;
17
18
  /**
@@ -19,5 +20,6 @@ export declare function decode(data: Encoded.Any): Buffer;
19
20
  * @param data - An decoded data
20
21
  * @param type - Prefix of Transaction
21
22
  * @returns Encoded string Base58check or Base64check data
23
+ * @category utils
22
24
  */
23
25
  export declare function encode<Type extends Encoding>(data: Uint8Array, type: Type): Encoded.Generic<Type>;
@@ -79,6 +79,7 @@ const parseType = maybeType => {
79
79
  * @param data - An Base58/64check encoded and prefixed string
80
80
  * (ex tx_..., sg_..., ak_....)
81
81
  * @returns Decoded data
82
+ * @category utils
82
83
  */
83
84
  export function decode(data) {
84
85
  const [prefix, encodedPayload, extra] = data.split('_');
@@ -95,6 +96,7 @@ export function decode(data) {
95
96
  * @param data - An decoded data
96
97
  * @param type - Prefix of Transaction
97
98
  * @returns Encoded string Base58check or Base64check data
99
+ * @category utils
98
100
  */
99
101
  export function encode(data, type) {
100
102
  const [, encoder] = parseType(type);
@@ -1 +1 @@
1
- {"version":3,"file":"encoder.js","names":["bs58","Sha256","DecodeError","ArgumentError","InvalidChecksumError","PayloadLengthError","concatBuffers","isKeyOfObject","Encoded","Encoding","sha256hash","input","update","digest","base64Types","ContractBytearray","ContractStoreKey","ContractStoreValue","Transaction","OracleQuery","OracleResponse","State","Poi","StateTrees","CallStateTree","Bytearray","base58Types","KeyBlockHash","MicroBlockHash","BlockPofHash","BlockTxHash","BlockStateHash","Channel","ContractAddress","TxHash","OracleAddress","OracleQueryId","AccountAddress","AccountSecretKey","Signature","Commitment","PeerPubkey","Name","byteSizeForType","ensureValidLength","data","type","reqLen","length","getChecksum","payload","slice","addChecksum","getPayload","buffer","equals","base64","encode","toString","decode","string","_Buffer","from","base58","parseType","maybeType","base64Type","find","t","base58Type","join","prefix","encodedPayload","extra","split","encoder"],"sources":["../../src/utils/encoder.ts"],"sourcesContent":["import bs58 from 'bs58';\n// js extension is required for mjs build, not importing the whole package to reduce bundle size\n// eslint-disable-next-line import/extensions\nimport Sha256 from 'sha.js/sha256.js';\nimport { DecodeError, ArgumentError, InvalidChecksumError, PayloadLengthError } from './errors.js';\nimport { concatBuffers, isKeyOfObject } from './other.js';\nimport * as Encoded from './encoder-types.js';\nimport { Encoding } from './encoder-types.js';\n\nexport { Encoded, Encoding };\n\n/**\n * Calculate SHA256 hash of `input`\n * @param input - Data to hash\n * @returns Hash\n */\nexport function sha256hash(input: Uint8Array | string): Buffer {\n return new Sha256().update(input).digest();\n}\n\n/**\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L177-L202}\n */\nconst base64Types = [\n Encoding.ContractBytearray,\n Encoding.ContractStoreKey,\n Encoding.ContractStoreValue,\n Encoding.Transaction,\n Encoding.OracleQuery,\n Encoding.OracleResponse,\n Encoding.State,\n Encoding.Poi,\n Encoding.StateTrees,\n Encoding.CallStateTree,\n Encoding.Bytearray,\n] as const;\nconst base58Types = [\n Encoding.KeyBlockHash,\n Encoding.MicroBlockHash,\n Encoding.BlockPofHash,\n Encoding.BlockTxHash,\n Encoding.BlockStateHash,\n Encoding.Channel,\n Encoding.ContractAddress,\n Encoding.TxHash,\n Encoding.OracleAddress,\n Encoding.OracleQueryId,\n Encoding.AccountAddress,\n Encoding.AccountSecretKey,\n Encoding.Signature,\n Encoding.Commitment,\n Encoding.PeerPubkey,\n Encoding.Name,\n] as const;\n\n/**\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L261-L286}\n */\nconst byteSizeForType = {\n [Encoding.KeyBlockHash]: 32,\n [Encoding.MicroBlockHash]: 32,\n [Encoding.BlockPofHash]: 32,\n [Encoding.BlockTxHash]: 32,\n [Encoding.BlockStateHash]: 32,\n [Encoding.Channel]: 32,\n [Encoding.ContractAddress]: 32,\n [Encoding.TxHash]: 32,\n [Encoding.OracleAddress]: 32,\n [Encoding.OracleQueryId]: 32,\n [Encoding.AccountAddress]: 32,\n [Encoding.AccountSecretKey]: 32,\n [Encoding.Signature]: 64,\n [Encoding.Commitment]: 32,\n [Encoding.PeerPubkey]: 32,\n [Encoding.State]: 32,\n} as const;\n\nfunction ensureValidLength(data: Uint8Array, type: Encoding): void {\n if (!isKeyOfObject(type, byteSizeForType)) return;\n const reqLen = byteSizeForType[type];\n if (reqLen == null || data.length === reqLen) return;\n throw new PayloadLengthError(`Payload should be ${reqLen} bytes, got ${data.length} instead`);\n}\n\nconst getChecksum = (payload: Uint8Array): Buffer => sha256hash(sha256hash(payload)).slice(0, 4);\n\nconst addChecksum = (payload: Uint8Array): Buffer => concatBuffers([payload, getChecksum(payload)]);\n\nfunction getPayload(buffer: Buffer): Buffer {\n const payload = buffer.slice(0, -4);\n if (!getChecksum(payload).equals(buffer.slice(-4))) throw new InvalidChecksumError();\n return payload;\n}\n\nconst base64 = {\n encode: (buffer: Uint8Array) => addChecksum(buffer).toString('base64'),\n decode: (string: string) => getPayload(Buffer.from(string, 'base64')),\n};\n\nconst base58 = {\n encode: (buffer: Uint8Array) => bs58.encode(addChecksum(buffer)),\n decode: (string: string) => getPayload(Buffer.from(bs58.decode(string))),\n};\n\nconst parseType = (maybeType: unknown): [Encoding, typeof base64] => {\n const base64Type = base64Types.find((t) => t === maybeType);\n if (base64Type != null) return [base64Type, base64];\n const base58Type = base58Types.find((t) => t === maybeType);\n if (base58Type != null) return [base58Type, base58];\n throw new ArgumentError(\n 'prefix',\n `one of ${[...base58Types, ...base64Types].join(', ')}`,\n maybeType,\n );\n};\n\n/**\n * Decode data using the default encoding/decoding algorithm\n * @param data - An Base58/64check encoded and prefixed string\n * (ex tx_..., sg_..., ak_....)\n * @returns Decoded data\n */\nexport function decode(data: Encoded.Any): Buffer {\n const [prefix, encodedPayload, extra] = data.split('_');\n if (encodedPayload == null) throw new DecodeError(`Encoded string missing payload: ${data}`);\n if (extra != null) throw new DecodeError(`Encoded string have extra parts: ${data}`);\n const [type, encoder] = parseType(prefix);\n const payload = encoder.decode(encodedPayload);\n ensureValidLength(payload, type);\n return payload;\n}\n\n/**\n * Encode data using the default encoding/decoding algorithm\n * @param data - An decoded data\n * @param type - Prefix of Transaction\n * @returns Encoded string Base58check or Base64check data\n */\nexport function encode<Type extends Encoding>(data: Uint8Array, type: Type): Encoded.Generic<Type> {\n const [, encoder] = parseType(type);\n ensureValidLength(data, type);\n return `${type}_${encoder.encode(data)}`;\n}\n"],"mappings":";AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB;AACA;AACA,OAAOC,MAAM,MAAM,kBAAkB;AACrC,SAASC,WAAW,EAAEC,aAAa,EAAEC,oBAAoB,EAAEC,kBAAkB,QAAQ,aAAa;AAClG,SAASC,aAAa,EAAEC,aAAa,QAAQ,YAAY;AACzD,OAAO,KAAKC,OAAO,MAAM,oBAAoB;AAC7C,SAASC,QAAQ,QAAQ,oBAAoB;AAE7C,SAASD,OAAO,EAAEC,QAAQ;;AAE1B;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,KAA0B,EAAU;EAC7D,OAAO,IAAIV,MAAM,CAAC,CAAC,CAACW,MAAM,CAACD,KAAK,CAAC,CAACE,MAAM,CAAC,CAAC;AAC5C;;AAEA;AACA;AACA;AACA,MAAMC,WAAW,GAAG,CAClBL,QAAQ,CAACM,iBAAiB,EAC1BN,QAAQ,CAACO,gBAAgB,EACzBP,QAAQ,CAACQ,kBAAkB,EAC3BR,QAAQ,CAACS,WAAW,EACpBT,QAAQ,CAACU,WAAW,EACpBV,QAAQ,CAACW,cAAc,EACvBX,QAAQ,CAACY,KAAK,EACdZ,QAAQ,CAACa,GAAG,EACZb,QAAQ,CAACc,UAAU,EACnBd,QAAQ,CAACe,aAAa,EACtBf,QAAQ,CAACgB,SAAS,CACV;AACV,MAAMC,WAAW,GAAG,CAClBjB,QAAQ,CAACkB,YAAY,EACrBlB,QAAQ,CAACmB,cAAc,EACvBnB,QAAQ,CAACoB,YAAY,EACrBpB,QAAQ,CAACqB,WAAW,EACpBrB,QAAQ,CAACsB,cAAc,EACvBtB,QAAQ,CAACuB,OAAO,EAChBvB,QAAQ,CAACwB,eAAe,EACxBxB,QAAQ,CA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ACnCF,iBAAiB,CAACC,IAAI,EAAEC,IAAI,CAAC;EAC7B,OAAO,GAAGA,IAAI,IAAI6B,OAAO,CAAClB,MAAM,CAACZ,IAAI,CAAC,EAAE;AAC1C","ignoreList":[]}
1
+ {"version":3,"file":"encoder.js","names":["bs58","Sha256","DecodeError","ArgumentError","InvalidChecksumError","PayloadLengthError","concatBuffers","isKeyOfObject","Encoded","Encoding","sha256hash","input","update","digest","base64Types","ContractBytearray","ContractStoreKey","ContractStoreValue","Transaction","OracleQuery","OracleResponse","State","Poi","StateTrees","CallStateTree","Bytearray","base58Types","KeyBlockHash","MicroBlockHash","BlockPofHash","BlockTxHash","BlockStateHash","Channel","ContractAddress","TxHash","OracleAddress","OracleQueryId","AccountAddress","AccountSecretKey","Signature","Commitment","PeerPubkey","Name","byteSizeForType","ensureValidLength","data","type","reqLen","length","getChecksum","payload","slice","addChecksum","getPayload","buffer","equals","base64","encode","toString","decode","string","_Buffer","from","base58","parseType","maybeType","base64Type","find","t","base58Type","join","prefix","encodedPayload","extra","split","encoder"],"sources":["../../src/utils/encoder.ts"],"sourcesContent":["import bs58 from 'bs58';\n// js extension is required for mjs build, not importing the whole package to reduce bundle size\n// eslint-disable-next-line import/extensions\nimport Sha256 from 'sha.js/sha256.js';\nimport { DecodeError, ArgumentError, InvalidChecksumError, PayloadLengthError } from './errors.js';\nimport { concatBuffers, isKeyOfObject } from './other.js';\nimport * as Encoded from './encoder-types.js';\nimport { Encoding } from './encoder-types.js';\n\nexport { Encoded, Encoding };\n\n/**\n * Calculate SHA256 hash of `input`\n * @param input - Data to hash\n * @returns Hash\n */\nexport function sha256hash(input: Uint8Array | string): Buffer {\n return new Sha256().update(input).digest();\n}\n\n/**\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L177-L202}\n */\nconst base64Types = [\n Encoding.ContractBytearray,\n Encoding.ContractStoreKey,\n Encoding.ContractStoreValue,\n Encoding.Transaction,\n Encoding.OracleQuery,\n Encoding.OracleResponse,\n Encoding.State,\n Encoding.Poi,\n Encoding.StateTrees,\n Encoding.CallStateTree,\n Encoding.Bytearray,\n] as const;\nconst base58Types = [\n Encoding.KeyBlockHash,\n Encoding.MicroBlockHash,\n Encoding.BlockPofHash,\n Encoding.BlockTxHash,\n Encoding.BlockStateHash,\n Encoding.Channel,\n Encoding.ContractAddress,\n Encoding.TxHash,\n Encoding.OracleAddress,\n Encoding.OracleQueryId,\n Encoding.AccountAddress,\n Encoding.AccountSecretKey,\n Encoding.Signature,\n Encoding.Commitment,\n Encoding.PeerPubkey,\n Encoding.Name,\n] as const;\n\n/**\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L261-L286}\n */\nconst byteSizeForType = {\n [Encoding.KeyBlockHash]: 32,\n [Encoding.MicroBlockHash]: 32,\n [Encoding.BlockPofHash]: 32,\n [Encoding.BlockTxHash]: 32,\n [Encoding.BlockStateHash]: 32,\n [Encoding.Channel]: 32,\n [Encoding.ContractAddress]: 32,\n [Encoding.TxHash]: 32,\n [Encoding.OracleAddress]: 32,\n [Encoding.OracleQueryId]: 32,\n [Encoding.AccountAddress]: 32,\n [Encoding.AccountSecretKey]: 32,\n [Encoding.Signature]: 64,\n [Encoding.Commitment]: 32,\n [Encoding.PeerPubkey]: 32,\n [Encoding.State]: 32,\n} as const;\n\nfunction ensureValidLength(data: Uint8Array, type: Encoding): void {\n if (!isKeyOfObject(type, byteSizeForType)) return;\n const reqLen = byteSizeForType[type];\n if (reqLen == null || data.length === reqLen) return;\n throw new PayloadLengthError(`Payload should be ${reqLen} bytes, got ${data.length} instead`);\n}\n\nconst getChecksum = (payload: Uint8Array): Buffer => sha256hash(sha256hash(payload)).slice(0, 4);\n\nconst addChecksum = (payload: Uint8Array): Buffer => concatBuffers([payload, getChecksum(payload)]);\n\nfunction getPayload(buffer: Buffer): Buffer {\n const payload = buffer.slice(0, -4);\n if (!getChecksum(payload).equals(buffer.slice(-4))) throw new InvalidChecksumError();\n return payload;\n}\n\nconst base64 = {\n encode: (buffer: Uint8Array) => addChecksum(buffer).toString('base64'),\n decode: (string: string) => getPayload(Buffer.from(string, 'base64')),\n};\n\nconst base58 = {\n encode: (buffer: Uint8Array) => bs58.encode(addChecksum(buffer)),\n decode: (string: string) => getPayload(Buffer.from(bs58.decode(string))),\n};\n\nconst parseType = (maybeType: unknown): [Encoding, typeof base64] => {\n const base64Type = base64Types.find((t) => t === maybeType);\n if (base64Type != null) return [base64Type, base64];\n const base58Type = base58Types.find((t) => t === maybeType);\n if (base58Type != null) return [base58Type, base58];\n throw new ArgumentError(\n 'prefix',\n `one of ${[...base58Types, ...base64Types].join(', ')}`,\n maybeType,\n );\n};\n\n/**\n * Decode data using the default encoding/decoding algorithm\n * @param data - An Base58/64check encoded and prefixed string\n * (ex tx_..., sg_..., ak_....)\n * @returns Decoded data\n * @category utils\n */\nexport function decode(data: Encoded.Any): Buffer {\n const [prefix, encodedPayload, extra] = data.split('_');\n if (encodedPayload == null) throw new DecodeError(`Encoded string missing payload: ${data}`);\n if (extra != null) throw new DecodeError(`Encoded string have extra parts: ${data}`);\n const [type, encoder] = parseType(prefix);\n const payload = encoder.decode(encodedPayload);\n ensureValidLength(payload, type);\n return payload;\n}\n\n/**\n * Encode data using the default encoding/decoding algorithm\n * @param data - An decoded data\n * @param type - Prefix of Transaction\n * @returns Encoded string Base58check or Base64check data\n * @category utils\n */\nexport function encode<Type extends Encoding>(data: Uint8Array, type: Type): Encoded.Generic<Type> {\n const [, encoder] = parseType(type);\n ensureValidLength(data, type);\n return `${type}_${encoder.encode(data)}`;\n}\n"],"mappings":";AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB;AACA;AACA,OAAOC,MAAM,MAAM,kBAAkB;AACrC,SAASC,WAAW,EAAEC,aAAa,EAAEC,oBAAoB,EAAEC,kBAAkB,QAAQ,aAAa;AAClG,SAASC,aAAa,EAAEC,aA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5D,aAAa,CACrB,QAAQ,EACR,UAAU,CAAC,GAAGuB,WAAW,EAAE,GAAGZ,WAAW,CAAC,CAACwD,IAAI,CAAC,IAAI,CAAC,EAAE,EACvDL,SACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASN,MAAMA,CAACd,IAAiB,EAAU;EAChD,MAAM,CAAC0B,MAAM,EAAEC,cAAc,EAAEC,KAAK,CAAC,GAAG5B,IAAI,CAAC6B,KAAK,CAAC,GAAG,CAAC;EACvD,IAAIF,cAAc,IAAI,IAAI,EAAE,MAAM,IAAItE,WAAW,CAAC,mCAAmC2C,IAAI,EAAE,CAAC;EAC5F,IAAI4B,KAAK,IAAI,IAAI,EAAE,MAAM,IAAIvE,WAAW,CAAC,oCAAoC2C,IAAI,EAAE,CAAC;EACpF,MAAM,CAACC,IAAI,EAAE6B,OAAO,CAAC,GAAGX,SAAS,CAACO,MAAM,CAAC;EACzC,MAAMrB,OAAO,GAAGyB,OAAO,CAAChB,MAAM,CAACa,cAAc,CAAC;EAC9C5B,iBAAiB,CAACM,OAAO,EAAEJ,IAAI,CAAC;EAChC,OAAOI,OAAO;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,MAAMA,CAAwBZ,IAAgB,EAAEC,IAAU,EAAyB;EACjG,MAAM,GAAG6B,OAAO,CAAC,GAAGX,SAAS,CAAClB,IAAI,CAAC;EACnCF,iBAAiB,CAACC,IAAI,EAAEC,IAAI,CAAC;EAC7B,OAAO,GAAGA,IAAI,IAAI6B,OAAO,CAAClB,MAAM,CAACZ,IAAI,CAAC,EAAE;AAC1C","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { BigNumber } from 'bignumber.js';
1
+ import BigNumber from 'bignumber.js';
2
2
  import { AensName, Int } from '../tx/builder/constants.js';
3
3
  import * as Encoded from './encoder-types.js';
4
4
  /**
@@ -270,7 +270,7 @@ export declare class InvalidAuthDataError extends CompilerError {
270
270
  * @category exception
271
271
  */
272
272
  export declare class BytecodeMismatchError extends ContractError {
273
- constructor(source: 'source code' | 'bytecode');
273
+ constructor(source: 'source code' | 'bytecode' | 'ACI', details?: string);
274
274
  }
275
275
  /**
276
276
  * @category exception
@@ -437,8 +437,8 @@ export class InvalidAuthDataError extends CompilerError {
437
437
  * @category exception
438
438
  */
439
439
  export class BytecodeMismatchError extends ContractError {
440
- constructor(source) {
441
- super(`Contract ${source} do not correspond to the bytecode deployed on the chain`);
440
+ constructor(source, details = '') {
441
+ super(`Contract ${source} do not correspond to the bytecode deployed on the chain` + details);
442
442
  this.name = 'BytecodeMismatchError';
443
443
  }
444
444
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["BaseError","Error","constructor","message","name","AccountError","AensError","AeppError","ChannelError","CompilerError","ContractError","CryptographyError","NodeError","TransactionError","WalletError","ArgumentError","argumentName","requirement","argumentValue","IllegalArgumentError","ArgumentCountMismatchError","functionName","requiredCount","providedCount","InsufficientBalanceError","MissingParamError","NoSerializerFoundError","RequestTimedOutError","height","TxTimedOutError","blocks","th","TypeError","UnsupportedPlatformError","UnsupportedProtocolError","NotImplementedError","UnsupportedVersionError","dependency","version","geVersion","ltVersion","LogicError","InternalError","UnexpectedTsError","UnavailableAccountError","address","AensPointerContextError","nameOrId","prefix","InsufficientNameFeeError","nameFee","minNameFee","toString","InvalidAensNameError","InvalidRpcMessageError","MissingCallbackError","id","UnAuthorizedAccountError","onAccount","UnknownRpcClientError","UnsubscribedAccountError","ChannelCallError","ChannelConnectionError","ChannelPingTimedOutError","UnexpectedChannelMessageError","ChannelIncomingMessageError","handlerError","incomingMessage","UnknownChannelStateError","InvalidAuthDataError","BytecodeMismatchError","source","DuplicateContractError","InactiveContractError","contractAddress","InvalidMethodInvocationError","MissingContractAddressError","MissingContractDefError","MissingFunctionNameError","NodeInvocationError","transaction","NoSuchContractFunctionError","NotPayableFunctionError","amount","fn","MissingEventDefinitionError","eventNameHash","eventAddress","AmbiguousEventDefinitionError","matchedEvents","map","join","InvalidChecksumError","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownNodeLengthError","nodeLength","UnknownPathNibbleError","nibble","DuplicateNodeError","NodeNotFoundError","DecodeError","PayloadLengthError","DryRunError","IllegalBidFeeError","InvalidSignatureError","PrefixNotFoundError","tag","SchemaNotFoundError","key","TagNotFoundError","TxNotInChainError","txHash","AlreadyConnectedError","NoWalletConnectedError","RpcConnectionError"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport { BigNumber } from 'bignumber.js';\nimport { AensName, Int } from '../tx/builder/constants.js';\nimport * as Encoded from './encoder-types.js';\n\n/**\n * aepp-sdk originated error\n * @category exception\n */\nexport abstract class BaseError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'BaseError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AccountError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AensError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AensError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AeppError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AeppError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelError';\n }\n}\n\n/**\n * @category exception\n */\nexport class CompilerError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'CompilerError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ContractError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'ContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class CryptographyError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'CryptographyError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'NodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TransactionError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'TransactionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class WalletError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'WalletError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentError extends BaseError {\n constructor(argumentName: string, requirement: unknown, argumentValue: unknown) {\n super(`${argumentName} should be ${requirement}, got ${argumentValue} instead`);\n this.name = 'ArgumentError';\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalArgumentError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'IllegalArgumentError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentCountMismatchError extends BaseError {\n constructor(functionName: string, requiredCount: number, providedCount: number) {\n super(`${functionName} expects ${requiredCount} arguments, got ${providedCount} instead`);\n this.name = 'ArgumentCountMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientBalanceError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'InsufficientBalanceError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingParamError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingParamError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSerializerFoundError extends BaseError {\n constructor() {\n super('Byte serialization not supported');\n this.name = 'NoSerializerFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class RequestTimedOutError extends BaseError {\n constructor(height: number) {\n super(`Giving up at height ${height}`);\n this.name = 'RequestTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TxTimedOutError extends BaseError {\n constructor(blocks: number, th: Encoded.TxHash) {\n super(`Giving up after ${blocks} blocks mined, transaction hash: ${th}`);\n this.name = 'TxTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TypeError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'TypeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedPlatformError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedPlatformError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedProtocolError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedProtocolError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NotImplementedError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'NotImplementedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedVersionError extends BaseError {\n constructor(dependency: string, version: string, geVersion: string, ltVersion?: string) {\n super(\n `Unsupported ${dependency} version ${version}. Supported: >= ${geVersion}` +\n (ltVersion == null ? '' : ` < ${ltVersion}`),\n );\n this.name = 'UnsupportedVersionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class LogicError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'LogicError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InternalError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'InternalError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedTsError extends InternalError {\n constructor(message = 'Expected to not happen, required for TS') {\n super(message);\n this.name = 'UnexpectedTsError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnavailableAccountError extends AccountError {\n constructor(address: Encoded.AccountAddress) {\n super(`Account for ${address} not available`);\n this.name = 'UnavailableAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AensPointerContextError extends AensError {\n constructor(nameOrId: AensName | Encoded.Name, prefix: string) {\n super(`Name ${nameOrId} don't have pointers for ${prefix}`);\n this.name = 'AensPointerContextError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientNameFeeError extends AensError {\n constructor(nameFee: BigNumber, minNameFee: BigNumber) {\n super(\n `the provided fee ${nameFee.toString()} is not enough to execute the claim, required: ${minNameFee.toString()}`,\n );\n this.name = 'InsufficientNameFeeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAensNameError extends AensError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidAensNameError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidRpcMessageError extends AeppError {\n constructor(message: string) {\n super(`Received invalid message: ${message}`);\n this.name = 'InvalidRpcMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingCallbackError extends AeppError {\n constructor(id: number) {\n super(`Can't find callback for this messageId ${id}`);\n this.name = 'MissingCallbackError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnAuthorizedAccountError extends AeppError {\n constructor(onAccount: Encoded.AccountAddress) {\n super(`You do not have access to account ${onAccount}`);\n this.name = 'UnAuthorizedAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownRpcClientError extends AeppError {\n constructor(id: string) {\n super(`RpcClient with id ${id} do not exist`);\n this.name = 'UnknownRpcClientError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsubscribedAccountError extends AeppError {\n constructor() {\n super('You are not subscribed for an account.');\n this.name = 'UnsubscribedAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelCallError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelCallError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelConnectionError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelConnectionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelPingTimedOutError extends ChannelError {\n constructor() {\n super('Server pong timed out');\n this.name = 'ChannelPingTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedChannelMessageError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'UnexpectedChannelMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelIncomingMessageError extends ChannelError {\n handlerError: Error;\n\n incomingMessage: { [key: string]: any };\n\n constructor(handlerError: Error, incomingMessage: { [key: string]: any }) {\n super(handlerError.message);\n this.handlerError = handlerError;\n this.incomingMessage = incomingMessage;\n this.name = 'ChannelIncomingMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownChannelStateError extends ChannelError {\n constructor() {\n super('State Channels FSM entered unknown state');\n this.name = 'UnknownChannelStateError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAuthDataError extends CompilerError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidAuthDataError';\n }\n}\n\n/**\n * @category exception\n */\nexport class BytecodeMismatchError extends ContractError {\n constructor(source: 'source code' | 'bytecode') {\n super(`Contract ${source} do not correspond to the bytecode deployed on the chain`);\n this.name = 'BytecodeMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateContractError extends ContractError {\n constructor() {\n super('Contract already deployed');\n this.name = 'DuplicateContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InactiveContractError extends ContractError {\n constructor(contractAddress: Encoded.ContractAddress) {\n super(`Contract with address ${contractAddress} not active`);\n this.name = 'InactiveContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidMethodInvocationError extends ContractError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidMethodInvocationError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractAddressError extends ContractError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingContractAddressError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractDefError extends ContractError {\n constructor() {\n super('Either ACI or sourceCode or sourceCodePath is required');\n this.name = 'MissingContractDefError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingFunctionNameError extends ContractError {\n constructor() {\n super('Function name is required');\n this.name = 'MissingFunctionNameError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeInvocationError extends ContractError {\n transaction?: Encoded.Transaction;\n\n constructor(message: string, transaction?: Encoded.Transaction) {\n super(`Invocation failed${message == null ? '' : `: \"${message}\"`}`);\n this.name = 'NodeInvocationError';\n this.transaction = transaction;\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSuchContractFunctionError extends ContractError {\n constructor(name: string) {\n super(`Function ${name} doesn't exist in contract`);\n this.name = 'NoSuchContractFunctionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NotPayableFunctionError extends ContractError {\n constructor(amount: Int, fn: string) {\n super(\n `You try to pay \"${amount}\" to function \"${fn}\" which is not payable. ` +\n 'Only payable function can accept coins',\n );\n this.name = 'NotPayableFunctionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingEventDefinitionError extends ContractError {\n constructor(eventNameHash: string, eventAddress: Encoded.ContractAddress) {\n super(\n `Can't find definition of ${eventNameHash} event emitted by ${eventAddress}` +\n ' (use omitUnknown option to ignore events like this)',\n );\n this.name = 'MissingEventDefinitionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AmbiguousEventDefinitionError extends ContractError {\n constructor(eventAddress: Encoded.ContractAddress, matchedEvents: Array<[string, string]>) {\n super(\n `Found multiple definitions of \"${matchedEvents[0][1]}\" event with different types emitted by` +\n ` ${eventAddress} in ${matchedEvents.map(([name]) => `\"${name}\"`).join(', ')} contracts` +\n ' (use contractAddressToName option to specify contract name corresponding to address)',\n );\n this.name = 'AmbiguousEventDefinitionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidChecksumError extends CryptographyError {\n constructor() {\n super('Invalid checksum');\n this.name = 'InvalidChecksumError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MerkleTreeHashMismatchError extends CryptographyError {\n constructor() {\n super('Node hash is not equal to provided one');\n this.name = 'MerkleTreeHashMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingNodeInTreeError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingNodeInTreeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownNodeLengthError extends CryptographyError {\n constructor(nodeLength: number) {\n super(`Unknown node length: ${nodeLength}`);\n this.name = 'UnknownNodeLengthError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownPathNibbleError extends CryptographyError {\n constructor(nibble: number) {\n super(`Unknown path nibble: ${nibble}`);\n this.name = 'UnknownPathNibbleError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateNodeError extends NodeError {\n constructor(name: string) {\n super(`Node with name ${name} already exist`);\n this.name = 'DuplicateNodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeNotFoundError extends NodeError {\n constructor(message: string) {\n super(message);\n this.name = 'NodeNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DecodeError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'DecodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class PayloadLengthError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'PayloadLengthError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DryRunError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'DryRunError';\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalBidFeeError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'IllegalBidFeeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidSignatureError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidSignatureError';\n }\n}\n\n/**\n * @category exception\n */\nexport class PrefixNotFoundError extends TransactionError {\n constructor(tag: number) {\n super(`Prefix for id-tag ${tag} not found.`);\n this.name = 'PrefixNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class SchemaNotFoundError extends TransactionError {\n constructor(key: string, version: number) {\n super(`Transaction schema not implemented for tag ${key} version ${version}`);\n this.name = 'SchemaNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TagNotFoundError extends TransactionError {\n constructor(prefix: string) {\n super(`Id tag for prefix ${prefix} not found.`);\n this.name = 'DecodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TxNotInChainError extends TransactionError {\n constructor(txHash: Encoded.TxHash) {\n super(`Transaction ${txHash} is removed from chain`);\n this.name = 'TxNotInChainError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AlreadyConnectedError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'AlreadyConnectedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NoWalletConnectedError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'NoWalletConnectedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class RpcConnectionError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'RpcConnectionError';\n }\n}\n"],"mappings":"AAAA;;AAKA;AACA;AACA;AACA;AACA,OAAO,MAAeA,SAAS,SAASC,KAAK,CAAC;EAC5CC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,WAAW;EACzB;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,SAASL,SAAS,CAAC;EAC1CE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,cAAc;EAC5B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAME,SAAS,SAASN,SAAS,CAAC;EACvCE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,WAAW;EACzB;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMG,SAAS,SAASP,SAAS,CAAC;EACvCE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,WAAW;EACzB;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMI,YAAY,SAASR,SAAS,CAAC;EAC1CE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,cAAc;EAC5B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMK,aAAa,SAAST,SAAS,CAAC;EAC3CE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,eAAe;EAC7B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMM,aAAa,SAASV,SAAS,CAAC;EAC3CE,WAAWA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CAAC,8CAA8CuE,GAAG,YAAYvE,OAAO,EAAE,CAAC;IAC7E,IAAI,CAAClC,IAAI,GAAG,qBAAqB;EACnC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAM0G,gBAAgB,SAASjG,gBAAgB,CAAC;EACrDX,WAAWA,CAAC8C,MAAc,EAAE;IAC1B,KAAK,CAAC,qBAAqBA,MAAM,aAAa,CAAC;IAC/C,IAAI,CAAC5C,IAAI,GAAG,aAAa;EAC3B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAM2G,iBAAiB,SAASlG,gBAAgB,CAAC;EACtDX,WAAWA,CAAC8G,MAAsB,EAAE;IAClC,KAAK,CAAC,eAAeA,MAAM,wBAAwB,CAAC;IACpD,IAAI,CAAC5G,IAAI,GAAG,mBAAmB;EACjC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAM6G,qBAAqB,SAASnG,WAAW,CAAC;EACrDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,uBAAuB;EACrC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAM8G,sBAAsB,SAASpG,WAAW,CAAC;EACtDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,wBAAwB;EACtC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAM+G,kBAAkB,SAASrG,WAAW,CAAC;EAClDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,oBAAoB;EAClC;AACF","ignoreList":[]}
1
+ {"version":3,"file":"errors.js","names":["BaseError","Error","constructor","message","name","AccountError","AensError","AeppError","ChannelError","CompilerError","ContractError","CryptographyError","NodeError","TransactionError","WalletError","ArgumentError","argumentName","requirement","argumentValue","IllegalArgumentError","ArgumentCountMismatchError","functionName","requiredCount","providedCount","InsufficientBalanceError","MissingParamError","NoSerializerFoundError","RequestTimedOutError","height","TxTimedOutError","blocks","th","TypeError","UnsupportedPlatformError","UnsupportedProtocolError","NotImplementedError","UnsupportedVersionError","dependency","version","geVersion","ltVersion","LogicError","InternalError","UnexpectedTsError","UnavailableAccountError","address","AensPointerContextError","nameOrId","prefix","InsufficientNameFeeError","nameFee","minNameFee","toString","InvalidAensNameError","InvalidRpcMessageError","MissingCallbackError","id","UnAuthorizedAccountError","onAccount","UnknownRpcClientError","UnsubscribedAccountError","ChannelCallError","ChannelConnectionError","ChannelPingTimedOutError","UnexpectedChannelMessageError","ChannelIncomingMessageError","handlerError","incomingMessage","UnknownChannelStateError","InvalidAuthDataError","BytecodeMismatchError","source","details","DuplicateContractError","InactiveContractError","contractAddress","InvalidMethodInvocationError","MissingContractAddressError","MissingContractDefError","MissingFunctionNameError","NodeInvocationError","transaction","NoSuchContractFunctionError","NotPayableFunctionError","amount","fn","MissingEventDefinitionError","eventNameHash","eventAddress","AmbiguousEventDefinitionError","matchedEvents","map","join","InvalidChecksumError","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownNodeLengthError","nodeLength","UnknownPathNibbleError","nibble","DuplicateNodeError","NodeNotFoundError","DecodeError","PayloadLengthError","DryRunError","IllegalBidFeeError","InvalidSignatureError","PrefixNotFoundError","tag","SchemaNotFoundError","key","TagNotFoundError","TxNotInChainError","txHash","AlreadyConnectedError","NoWalletConnectedError","RpcConnectionError"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport BigNumber from 'bignumber.js';\nimport { AensName, Int } from '../tx/builder/constants.js';\nimport * as Encoded from './encoder-types.js';\n\n/**\n * aepp-sdk originated error\n * @category exception\n */\nexport abstract class BaseError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'BaseError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AccountError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AensError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AensError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AeppError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AeppError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelError';\n }\n}\n\n/**\n * @category exception\n */\nexport class CompilerError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'CompilerError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ContractError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'ContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class CryptographyError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'CryptographyError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'NodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TransactionError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'TransactionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class WalletError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'WalletError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentError extends BaseError {\n constructor(argumentName: string, requirement: unknown, argumentValue: unknown) {\n super(`${argumentName} should be ${requirement}, got ${argumentValue} instead`);\n this.name = 'ArgumentError';\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalArgumentError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'IllegalArgumentError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentCountMismatchError extends BaseError {\n constructor(functionName: string, requiredCount: number, providedCount: number) {\n super(`${functionName} expects ${requiredCount} arguments, got ${providedCount} instead`);\n this.name = 'ArgumentCountMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientBalanceError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'InsufficientBalanceError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingParamError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingParamError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSerializerFoundError extends BaseError {\n constructor() {\n super('Byte serialization not supported');\n this.name = 'NoSerializerFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class RequestTimedOutError extends BaseError {\n constructor(height: number) {\n super(`Giving up at height ${height}`);\n this.name = 'RequestTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TxTimedOutError extends BaseError {\n constructor(blocks: number, th: Encoded.TxHash) {\n super(`Giving up after ${blocks} blocks mined, transaction hash: ${th}`);\n this.name = 'TxTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TypeError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'TypeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedPlatformError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedPlatformError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedProtocolError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedProtocolError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NotImplementedError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'NotImplementedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedVersionError extends BaseError {\n constructor(dependency: string, version: string, geVersion: string, ltVersion?: string) {\n super(\n `Unsupported ${dependency} version ${version}. Supported: >= ${geVersion}` +\n (ltVersion == null ? '' : ` < ${ltVersion}`),\n );\n this.name = 'UnsupportedVersionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class LogicError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'LogicError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InternalError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'InternalError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedTsError extends InternalError {\n constructor(message = 'Expected to not happen, required for TS') {\n super(message);\n this.name = 'UnexpectedTsError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnavailableAccountError extends AccountError {\n constructor(address: Encoded.AccountAddress) {\n super(`Account for ${address} not available`);\n this.name = 'UnavailableAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AensPointerContextError extends AensError {\n constructor(nameOrId: AensName | Encoded.Name, prefix: string) {\n super(`Name ${nameOrId} don't have pointers for ${prefix}`);\n this.name = 'AensPointerContextError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientNameFeeError extends AensError {\n constructor(nameFee: BigNumber, minNameFee: BigNumber) {\n super(\n `the provided fee ${nameFee.toString()} is not enough to execute the claim, required: ${minNameFee.toString()}`,\n );\n this.name = 'InsufficientNameFeeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAensNameError extends AensError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidAensNameError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidRpcMessageError extends AeppError {\n constructor(message: string) {\n super(`Received invalid message: ${message}`);\n this.name = 'InvalidRpcMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingCallbackError extends AeppError {\n constructor(id: number) {\n super(`Can't find callback for this messageId ${id}`);\n this.name = 'MissingCallbackError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnAuthorizedAccountError extends AeppError {\n constructor(onAccount: Encoded.AccountAddress) {\n super(`You do not have access to account ${onAccount}`);\n this.name = 'UnAuthorizedAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownRpcClientError extends AeppError {\n constructor(id: string) {\n super(`RpcClient with id ${id} do not exist`);\n this.name = 'UnknownRpcClientError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsubscribedAccountError extends AeppError {\n constructor() {\n super('You are not subscribed for an account.');\n this.name = 'UnsubscribedAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelCallError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelCallError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelConnectionError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelConnectionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelPingTimedOutError extends ChannelError {\n constructor() {\n super('Server pong timed out');\n this.name = 'ChannelPingTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedChannelMessageError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'UnexpectedChannelMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelIncomingMessageError extends ChannelError {\n handlerError: Error;\n\n incomingMessage: { [key: string]: any };\n\n constructor(handlerError: Error, incomingMessage: { [key: string]: any }) {\n super(handlerError.message);\n this.handlerError = handlerError;\n this.incomingMessage = incomingMessage;\n this.name = 'ChannelIncomingMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownChannelStateError extends ChannelError {\n constructor() {\n super('State Channels FSM entered unknown state');\n this.name = 'UnknownChannelStateError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAuthDataError extends CompilerError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidAuthDataError';\n }\n}\n\n/**\n * @category exception\n */\nexport class BytecodeMismatchError extends ContractError {\n constructor(source: 'source code' | 'bytecode' | 'ACI', details: string = '') {\n super(`Contract ${source} do not correspond to the bytecode deployed on the chain` + details);\n this.name = 'BytecodeMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateContractError extends ContractError {\n constructor() {\n super('Contract already deployed');\n this.name = 'DuplicateContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InactiveContractError extends ContractError {\n constructor(contractAddress: Encoded.ContractAddress) {\n super(`Contract with address ${contractAddress} not active`);\n this.name = 'InactiveContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidMethodInvocationError extends ContractError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidMethodInvocationError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractAddressError extends ContractError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingContractAddressError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractDefError extends ContractError {\n constructor() {\n super('Either ACI or sourceCode or sourceCodePath is required');\n this.name = 'MissingContractDefError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingFunctionNameError extends ContractError {\n constructor() {\n super('Function name is required');\n this.name = 'MissingFunctionNameError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeInvocationError extends ContractError {\n transaction?: Encoded.Transaction;\n\n constructor(message: string, transaction?: Encoded.Transaction) {\n super(`Invocation failed${message == null ? '' : `: \"${message}\"`}`);\n this.name = 'NodeInvocationError';\n this.transaction = transaction;\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSuchContractFunctionError extends ContractError {\n constructor(name: string) {\n super(`Function ${name} doesn't exist in contract`);\n this.name = 'NoSuchContractFunctionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NotPayableFunctionError extends ContractError {\n constructor(amount: Int, fn: string) {\n super(\n `You try to pay \"${amount}\" to function \"${fn}\" which is not payable. ` +\n 'Only payable function can accept coins',\n );\n this.name = 'NotPayableFunctionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingEventDefinitionError extends ContractError {\n constructor(eventNameHash: string, eventAddress: Encoded.ContractAddress) {\n super(\n `Can't find definition of ${eventNameHash} event emitted by ${eventAddress}` +\n ' (use omitUnknown option to ignore events like this)',\n );\n this.name = 'MissingEventDefinitionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AmbiguousEventDefinitionError extends ContractError {\n constructor(eventAddress: Encoded.ContractAddress, matchedEvents: Array<[string, string]>) {\n super(\n `Found multiple definitions of \"${matchedEvents[0][1]}\" event with different types emitted by` +\n ` ${eventAddress} in ${matchedEvents.map(([name]) => `\"${name}\"`).join(', ')} contracts` +\n ' (use contractAddressToName option to specify contract name corresponding to address)',\n );\n this.name = 'AmbiguousEventDefinitionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidChecksumError extends CryptographyError {\n constructor() {\n super('Invalid checksum');\n this.name = 'InvalidChecksumError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MerkleTreeHashMismatchError extends CryptographyError {\n constructor() {\n super('Node hash is not equal to provided one');\n this.name = 'MerkleTreeHashMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingNodeInTreeError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingNodeInTreeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownNodeLengthError extends CryptographyError {\n constructor(nodeLength: number) {\n super(`Unknown node length: ${nodeLength}`);\n this.name = 'UnknownNodeLengthError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownPathNibbleError extends CryptographyError {\n constructor(nibble: number) {\n super(`Unknown path nibble: ${nibble}`);\n this.name = 'UnknownPathNibbleError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateNodeError extends NodeError {\n constructor(name: string) {\n super(`Node with name ${name} already exist`);\n this.name = 'DuplicateNodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeNotFoundError extends NodeError {\n constructor(message: string) {\n super(message);\n this.name = 'NodeNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DecodeError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'DecodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class PayloadLengthError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'PayloadLengthError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DryRunError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'DryRunError';\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalBidFeeError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'IllegalBidFeeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidSignatureError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidSignatureError';\n }\n}\n\n/**\n * @category exception\n */\nexport class PrefixNotFoundError extends TransactionError {\n constructor(tag: number) {\n super(`Prefix for id-tag ${tag} not found.`);\n this.name = 'PrefixNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class SchemaNotFoundError extends TransactionError {\n constructor(key: string, version: number) {\n super(`Transaction schema not implemented for tag ${key} version ${version}`);\n this.name = 'SchemaNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TagNotFoundError extends TransactionError {\n constructor(prefix: string) {\n super(`Id tag for prefix ${prefix} not found.`);\n this.name = 'DecodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TxNotInChainError extends TransactionError {\n constructor(txHash: Encoded.TxHash) {\n super(`Transaction ${txHash} is removed from chain`);\n this.name = 'TxNotInChainError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AlreadyConnectedError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'AlreadyConnectedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NoWalletConnectedError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'NoWalletConnectedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class RpcConnectionError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'RpcConnectionError';\n }\n}\n"],"mappings":"AAAA;;AAKA;AACA;AACA;AACA;AACA,OAAO,MAAeA,SAAS,SAASC,KAAK,CAAC;EAC5CC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,WAAW;EACzB;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,SAASL,SAAS,CAAC;EAC1CE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,cAAc;EAC5B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAME,SAAS,SAASN,SAAS,CAAC;EACvCE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAA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C;EACrDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,uBAAuB;EACrC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAM+G,sBAAsB,SAASrG,WAAW,CAAC;EACtDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,wBAAwB;EACtC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMgH,kBAAkB,SAAStG,WAAW,CAAC;EAClDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,oBAAoB;EAClC;AACF","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import JsonBig from 'json-bigint';
2
- import { BigNumber } from 'bignumber.js';
2
+ import BigNumber from 'bignumber.js';
3
3
  import { mapObject } from './other.js';
4
4
  const jsonBig = JsonBig({
5
5
  storeAsString: true
@@ -1 +1 @@
1
- {"version":3,"file":"json-big.js","names":["JsonBig","BigNumber","mapObject","jsonBig","storeAsString","convertValuesToBigNumbers","value","constructor","Object","k","v","Array","isArray","map","item","toString","bn","toJSON","stringify","args","slice","parse"],"sources":["../../src/utils/json-big.ts"],"sourcesContent":["import JsonBig from 'json-bigint';\nimport { BigNumber } from 'bignumber.js';\nimport { mapObject } from './other.js';\n\nconst jsonBig = JsonBig({ storeAsString: true });\n\nconst convertValuesToBigNumbers = (value: any): any => {\n if (typeof value === 'object' && value !== null && value.constructor === Object) {\n return mapObject(value, ([k, v]) => [k, convertValuesToBigNumbers(v)]);\n }\n if (Array.isArray(value)) {\n return value.map((item) => convertValuesToBigNumbers(item));\n }\n if (typeof value === 'string' && new BigNumber(value).toString(10) === value) {\n const bn = new BigNumber(value);\n bn.toJSON = () => bn.toString(10);\n return bn;\n }\n return value;\n};\n\nexport default {\n stringify: (...args: Parameters<(typeof JsonBig)['stringify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ACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"json-big.js","names":["JsonBig","BigNumber","mapObject","jsonBig","storeAsString","convertValuesToBigNumbers","value","constructor","Object","k","v","Array","isArray","map","item","toString","bn","toJSON","stringify","args","slice","parse"],"sources":["../../src/utils/json-big.ts"],"sourcesContent":["import JsonBig from 'json-bigint';\nimport BigNumber from 'bignumber.js';\nimport { mapObject } from './other.js';\n\nconst jsonBig = JsonBig({ storeAsString: true });\n\nconst convertValuesToBigNumbers = (value: any): any => {\n if (typeof value === 'object' && value !== null && value.constructor === Object) {\n return mapObject(value, ([k, v]) => [k, convertValuesToBigNumbers(v)]);\n }\n if (Array.isArray(value)) {\n return value.map((item) => convertValuesToBigNumbers(item));\n }\n if (typeof value === 'string' && new BigNumber(value).toString(10) === value) {\n const bn = new BigNumber(value);\n bn.toJSON = () => bn.toString(10);\n return bn;\n }\n return value;\n};\n\nexport default {\n stringify: (...args: Parameters<(typeof JsonBig)['stringify']>): string =>\n jsonBig.stringify(convertValuesToBigNumbers(args[0]), ...args.slice(1)),\n parse: jsonBig.parse,\n};\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,aAAa;AACjC,OAAOC,SAAS,MAAM,cAAc;AACpC,SAASC,SAAS,QAAQ,YAAY;AAEtC,MAAMC,OAAO,GAAGH,OAAO,CAAC;EAAEI,aAAa,EAAE;AAAK,CAAC,CAAC;AAEhD,MAAMC,yBAAyB,GAAIC,KAAU,IAAU;EACrD,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,CAACC,WAAW,KAAKC,MAAM,EAAE;IAC/E,OAAON,SAAS,CAACI,KAAK,EAAE,CAAC,CAACG,CAAC,EAAEC,CAAC,CAAC,KAAK,CAACD,CAAC,EAAEJ,yBAAyB,CAACK,CAAC,CAAC,CAAC,CAAC;EACxE;EACA,IAAIC,KAAK,CAACC,OAAO,CAACN,KAAK,CAAC,EAAE;IACxB,OAAOA,KAAK,CAACO,GAAG,CAAEC,IAAI,IAAKT,yBAAyB,CAACS,IAAI,CAAC,CAAC;EAC7D;EACA,IAAI,OAAOR,KAAK,KAAK,QAAQ,IAAI,IAAIL,SAAS,CAACK,KAAK,CAAC,CAACS,QAAQ,CAAC,EAAE,CAAC,KAAKT,KAAK,EAAE;IAC5E,MAAMU,EAAE,GAAG,IAAIf,SAAS,CAACK,KAAK,CAAC;IAC/BU,EAAE,CAACC,MAAM,GAAG,MAAMD,EAAE,CAACD,QAAQ,CAAC,EAAE,CAAC;IACjC,OAAOC,EAAE;EACX;EACA,OAAOV,KAAK;AACd,CAAC;AAED,eAAe;EACbY,SAAS,EAAEA,CAAC,GAAGC,IAA+C,KAC5DhB,OAAO,CAACe,SAAS,CAACb,yBAAyB,CAACc,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,GAAGA,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC;EACzEC,KAAK,EAAElB,OAAO,CAACkB;AACjB,CAAC","ignoreList":[]}
package/es/utils/jwt.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Buffer as _Buffer } from "buffer";
2
2
  import canonicalize from 'canonicalize';
3
3
  import { Encoding, decode, encode } from './encoder.js';
4
- import { verify } from './crypto.js';
4
+ import { verifySignature } from './crypto.js';
5
5
  import { ArgumentError, InvalidSignatureError } from './errors.js';
6
6
 
7
7
  // TODO: use Buffer.from(data, 'base64url') after solving https://github.com/feross/buffer/issues/309
@@ -38,7 +38,7 @@ export async function signJwt(originalPayload, account) {
38
38
  }
39
39
  if (payload.sub_jwk === undefined) delete payload.sub_jwk;
40
40
  const body = `${header}.${objectToBase64Url(payload)}`;
41
- const signature = await account.sign(body);
41
+ const signature = await account.unsafeSign(body);
42
42
  return `${body}.${toBase64Url(signature)}`;
43
43
  }
44
44
 
@@ -60,7 +60,7 @@ export function unpackJwt(jwt, address) {
60
60
  if (address != null && signer !== address) {
61
61
  throw new ArgumentError('address', `${signer} ("sub_jwk")`, address);
62
62
  }
63
- if (signer != null && !verify(_Buffer.from(`${h}.${payloadEncoded}`), fromBase64Url(signature), signer)) {
63
+ if (signer != null && !verifySignature(_Buffer.from(`${h}.${payloadEncoded}`), fromBase64Url(signature), signer)) {
64
64
  throw new InvalidSignatureError(`JWT is not signed by ${signer}`);
65
65
  }
66
66
  return {