@aeternity/aepp-sdk 13.0.1 → 13.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/bin/aesophia_cli +0 -0
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +26702 -16514
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdkBase.d.ts +11 -3
- package/es/AeSdkBase.mjs +24 -3
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +9 -14
- package/es/AeSdkMethods.mjs +20 -49
- package/es/AeSdkMethods.mjs.map +1 -1
- package/es/AeSdkWallet.mjs +28 -5
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Middleware.d.ts +38 -0
- package/es/Middleware.mjs +90 -0
- package/es/Middleware.mjs.map +1 -0
- package/es/MiddlewareSubscriber.d.ts +30 -0
- package/es/MiddlewareSubscriber.mjs +198 -0
- package/es/MiddlewareSubscriber.mjs.map +1 -0
- package/es/Node.d.ts +1 -1
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +14 -2
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.d.ts +1 -0
- package/es/account/Generalized.mjs +5 -0
- package/es/account/Generalized.mjs.map +1 -1
- package/es/account/Ledger.d.ts +1 -0
- package/es/account/Ledger.mjs +5 -0
- package/es/account/Ledger.mjs.map +1 -1
- package/es/account/Memory.d.ts +2 -0
- package/es/account/Memory.mjs +18 -0
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.d.ts +1 -6
- package/es/account/Rpc.mjs +24 -10
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +1 -1
- package/es/aens.mjs +1 -1
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -2
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +10 -0
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.d.ts +1 -8
- package/es/aepp-wallet-communication/schema.mjs +1 -14
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.d.ts +1 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/compiler/compiler.mjs +15 -1
- package/es/apis/compiler/compiler.mjs.map +1 -1
- package/es/apis/compiler/models/index.d.ts +1 -7
- package/es/apis/compiler/models/index.mjs.map +1 -1
- package/es/apis/compiler/models/mappers.d.ts +0 -1
- package/es/apis/compiler/models/mappers.mjs +0 -43
- package/es/apis/compiler/models/mappers.mjs.map +1 -1
- package/es/apis/middleware/index.d.ts +2 -0
- package/es/apis/middleware/index.mjs +3 -0
- package/es/apis/middleware/index.mjs.map +1 -0
- package/es/apis/middleware/middleware.d.ts +309 -0
- package/es/apis/middleware/middleware.mjs +1527 -0
- package/es/apis/middleware/middleware.mjs.map +1 -0
- package/es/apis/middleware/models/index.d.ts +1496 -0
- package/es/apis/middleware/models/index.mjs +364 -0
- package/es/apis/middleware/models/index.mjs.map +1 -0
- package/es/apis/middleware/models/mappers.d.ts +102 -0
- package/es/apis/middleware/models/mappers.mjs +3334 -0
- package/es/apis/middleware/models/mappers.mjs.map +1 -0
- package/es/apis/middleware/models/parameters.d.ts +43 -0
- package/es/apis/middleware/models/parameters.mjs +417 -0
- package/es/apis/middleware/models/parameters.mjs.map +1 -0
- package/es/chain.d.ts +2 -1
- package/es/chain.mjs +4 -2
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +1 -1
- package/es/channel/Base.mjs +1 -4
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/internal.mjs +2 -0
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.mjs +1 -1
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +21 -0
- package/es/contract/compiler/Base.mjs.map +1 -1
- package/es/contract/compiler/Cli.d.ts +2 -0
- package/es/contract/compiler/Cli.mjs +24 -3
- package/es/contract/compiler/Cli.mjs.map +1 -1
- package/es/contract/compiler/Http.d.ts +2 -0
- package/es/contract/compiler/Http.mjs +22 -2
- package/es/contract/compiler/Http.mjs.map +1 -1
- package/es/contract/compiler/HttpNode.d.ts +1 -0
- package/es/contract/compiler/HttpNode.mjs +5 -0
- package/es/contract/compiler/HttpNode.mjs.map +1 -1
- package/es/deprecated.d.ts +14 -0
- package/es/deprecated.mjs +22 -0
- package/es/deprecated.mjs.map +1 -0
- package/es/index-browser.d.ts +20 -14
- package/es/index-browser.mjs +19 -15
- package/es/index-browser.mjs.map +1 -1
- package/es/tx/builder/constants.d.ts +0 -1
- package/es/tx/builder/constants.mjs +0 -1
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/coin-amount.d.ts +1 -1
- package/es/tx/builder/field-types/coin-amount.mjs +2 -1
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/deposit.d.ts +1 -1
- package/es/tx/builder/field-types/entry.mjs +2 -1
- package/es/tx/builder/field-types/entry.mjs.map +1 -1
- package/es/tx/builder/field-types/index.d.ts +2 -2
- package/es/tx/builder/helpers.d.ts +8 -1
- package/es/tx/builder/helpers.mjs +53 -9
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +4 -2
- package/es/tx/builder/index.mjs +0 -1
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +9 -9
- package/es/tx/validator.mjs +6 -3
- package/es/tx/validator.mjs.map +1 -1
- package/es/utils/autorest.mjs +6 -8
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/crypto.d.ts +1 -0
- package/es/utils/crypto.mjs +12 -2
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/errors.d.ts +2 -2
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/other.d.ts +1 -0
- package/es/utils/other.mjs +5 -0
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/typed-data.d.ts +45 -0
- package/es/utils/typed-data.mjs +71 -0
- package/es/utils/typed-data.mjs.map +1 -0
- package/package.json +23 -4
- package/src/AeSdkBase.ts +30 -5
- package/src/AeSdkMethods.ts +31 -50
- package/src/AeSdkWallet.ts +27 -5
- package/src/Middleware.ts +141 -0
- package/src/MiddlewareSubscriber.ts +207 -0
- package/src/Node.ts +1 -1
- package/src/account/Base.ts +20 -3
- package/src/account/Generalized.ts +5 -0
- package/src/account/Ledger.ts +5 -0
- package/src/account/Memory.ts +15 -0
- package/src/account/Rpc.ts +19 -7
- package/src/aens.ts +1 -1
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +11 -3
- package/src/aepp-wallet-communication/rpc/types.ts +11 -0
- package/src/aepp-wallet-communication/schema.ts +2 -17
- package/src/aepp-wallet-communication/wallet-detector.ts +1 -2
- package/src/apis/compiler/compiler.ts +8 -1
- package/src/apis/compiler/models/index.ts +1 -8
- package/src/apis/compiler/models/mappers.ts +0 -36
- package/src/apis/middleware/index.ts +2 -0
- package/src/apis/middleware/middleware.ts +1807 -0
- package/src/apis/middleware/models/index.ts +1747 -0
- package/src/apis/middleware/models/mappers.ts +3370 -0
- package/src/apis/middleware/models/parameters.ts +463 -0
- package/src/chain.ts +3 -2
- package/src/channel/Base.ts +5 -5
- package/src/channel/internal.ts +2 -0
- package/src/contract/Contract.ts +1 -0
- package/src/contract/compiler/Base.ts +26 -0
- package/src/contract/compiler/Cli.ts +27 -3
- package/src/contract/compiler/Http.ts +21 -2
- package/src/contract/compiler/HttpNode.ts +6 -0
- package/src/deprecated.ts +23 -0
- package/src/index-browser.ts +77 -15
- package/src/tx/builder/constants.ts +0 -1
- package/src/tx/builder/field-types/coin-amount.ts +2 -1
- package/src/tx/builder/field-types/entry.ts +1 -1
- package/src/tx/builder/helpers.ts +54 -9
- package/src/tx/builder/index.ts +6 -9
- package/src/tx/validator.ts +4 -2
- package/src/utils/autorest.ts +5 -10
- package/src/utils/crypto.ts +12 -2
- package/src/utils/errors.ts +2 -2
- package/src/utils/other.ts +5 -0
- package/src/utils/typed-data.ts +95 -0
- package/types-legacy/ts4.2/AeSdkBase.d.ts +11 -3
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +9 -14
- package/types-legacy/ts4.2/Middleware.d.ts +46 -0
- package/types-legacy/ts4.2/MiddlewareSubscriber.d.ts +30 -0
- package/types-legacy/ts4.2/Node.d.ts +1 -1
- package/types-legacy/ts4.2/account/Base.d.ts +14 -2
- package/types-legacy/ts4.2/account/Generalized.d.ts +1 -0
- package/types-legacy/ts4.2/account/Ledger.d.ts +1 -0
- package/types-legacy/ts4.2/account/Memory.d.ts +2 -0
- package/types-legacy/ts4.2/account/Rpc.d.ts +1 -6
- package/types-legacy/ts4.2/aens.d.ts +1 -1
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +10 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +1 -8
- package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +1 -1
- package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +1 -7
- package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +0 -1
- package/types-legacy/ts4.2/apis/middleware/index.d.ts +2 -0
- package/types-legacy/ts4.2/apis/middleware/middleware.d.ts +309 -0
- package/types-legacy/ts4.2/apis/middleware/models/index.d.ts +1496 -0
- package/types-legacy/ts4.2/apis/middleware/models/mappers.d.ts +102 -0
- package/types-legacy/ts4.2/apis/middleware/models/parameters.d.ts +43 -0
- package/types-legacy/ts4.2/chain.d.ts +2 -1
- package/types-legacy/ts4.2/channel/Base.d.ts +1 -1
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +21 -0
- package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +2 -0
- package/types-legacy/ts4.2/contract/compiler/Http.d.ts +2 -0
- package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +1 -0
- package/types-legacy/ts4.2/deprecated.d.ts +14 -0
- package/types-legacy/ts4.2/index-browser.d.ts +20 -14
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +0 -1
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +2 -2
- package/types-legacy/ts4.2/tx/builder/helpers.d.ts +8 -1
- package/types-legacy/ts4.2/tx/builder/index.d.ts +4 -2
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +9 -9
- package/types-legacy/ts4.2/utils/crypto.d.ts +1 -0
- package/types-legacy/ts4.2/utils/errors.d.ts +2 -2
- package/types-legacy/ts4.2/utils/other.d.ts +1 -0
- package/types-legacy/ts4.2/utils/typed-data.d.ts +60 -0
- package/types-legacy/ts4.5/AeSdkBase.d.ts +11 -3
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +9 -14
- package/types-legacy/ts4.5/Middleware.d.ts +46 -0
- package/types-legacy/ts4.5/MiddlewareSubscriber.d.ts +30 -0
- package/types-legacy/ts4.5/Node.d.ts +1 -1
- package/types-legacy/ts4.5/account/Base.d.ts +14 -2
- package/types-legacy/ts4.5/account/Generalized.d.ts +1 -0
- package/types-legacy/ts4.5/account/Ledger.d.ts +1 -0
- package/types-legacy/ts4.5/account/Memory.d.ts +2 -0
- package/types-legacy/ts4.5/account/Rpc.d.ts +1 -6
- package/types-legacy/ts4.5/aens.d.ts +1 -1
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +10 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +1 -8
- package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +1 -1
- package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +1 -7
- package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +0 -1
- package/types-legacy/ts4.5/apis/middleware/index.d.ts +2 -0
- package/types-legacy/ts4.5/apis/middleware/middleware.d.ts +309 -0
- package/types-legacy/ts4.5/apis/middleware/models/index.d.ts +1496 -0
- package/types-legacy/ts4.5/apis/middleware/models/mappers.d.ts +102 -0
- package/types-legacy/ts4.5/apis/middleware/models/parameters.d.ts +43 -0
- package/types-legacy/ts4.5/chain.d.ts +2 -1
- package/types-legacy/ts4.5/channel/Base.d.ts +1 -1
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +21 -0
- package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +2 -0
- package/types-legacy/ts4.5/contract/compiler/Http.d.ts +2 -0
- package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +1 -0
- package/types-legacy/ts4.5/deprecated.d.ts +14 -0
- package/types-legacy/ts4.5/index-browser.d.ts +20 -14
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +0 -1
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +2 -2
- package/types-legacy/ts4.5/tx/builder/helpers.d.ts +8 -1
- package/types-legacy/ts4.5/tx/builder/index.d.ts +4 -2
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +9 -9
- package/types-legacy/ts4.5/utils/crypto.d.ts +1 -0
- package/types-legacy/ts4.5/utils/errors.d.ts +2 -2
- package/types-legacy/ts4.5/utils/other.d.ts +1 -0
- package/types-legacy/ts4.5/utils/typed-data.d.ts +60 -0
package/es/utils/crypto.mjs
CHANGED
|
@@ -15,6 +15,7 @@ const {
|
|
|
15
15
|
} = _varuintBitcoin;
|
|
16
16
|
import { concatBuffers } from "./other.mjs";
|
|
17
17
|
import { decode, encode, Encoding } from "./encoder.mjs";
|
|
18
|
+
import { ArgumentError } from "./errors.mjs";
|
|
18
19
|
/**
|
|
19
20
|
* Generate address from secret key
|
|
20
21
|
* @param secret - Private key as hex string
|
|
@@ -36,6 +37,10 @@ export function isAddressValid(address) {
|
|
|
36
37
|
let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Encoding.AccountAddress;
|
|
37
38
|
try {
|
|
38
39
|
decode(address);
|
|
40
|
+
const actualPrefix = address.split('_')[0];
|
|
41
|
+
if (actualPrefix !== prefix) {
|
|
42
|
+
throw new ArgumentError('Encoded string type', prefix, actualPrefix);
|
|
43
|
+
}
|
|
39
44
|
return true;
|
|
40
45
|
} catch (e) {
|
|
41
46
|
return false;
|
|
@@ -142,10 +147,13 @@ export function sign(data, privateKey) {
|
|
|
142
147
|
export function verify(data, signature, address) {
|
|
143
148
|
return nacl.sign.detached.verify(data, signature, decode(address));
|
|
144
149
|
}
|
|
150
|
+
const messagePrefix = _Buffer.from('aeternity Signed Message:\n', 'utf8');
|
|
151
|
+
export const messagePrefixLength = varuintEncode(messagePrefix.length);
|
|
152
|
+
|
|
153
|
+
// TODO: consider rename to hashMessage
|
|
145
154
|
export function messageToHash(message) {
|
|
146
|
-
const p = _Buffer.from('aeternity Signed Message:\n', 'utf8');
|
|
147
155
|
const msg = _Buffer.from(message, 'utf8');
|
|
148
|
-
return hash(concatBuffers([
|
|
156
|
+
return hash(concatBuffers([messagePrefixLength, messagePrefix, varuintEncode(msg.length), msg]));
|
|
149
157
|
}
|
|
150
158
|
export function signMessage(message, privateKey) {
|
|
151
159
|
return sign(messageToHash(message), privateKey);
|
|
@@ -158,6 +166,8 @@ export function signMessage(message, privateKey) {
|
|
|
158
166
|
* @param address - Address to verify against
|
|
159
167
|
* @returns is data was signed by address
|
|
160
168
|
*/
|
|
169
|
+
// TODO: deprecate in favour of `verify(messageToHash(message), ...`, also the name is confusing
|
|
170
|
+
// it should contain "signature"
|
|
161
171
|
export function verifyMessage(message, signature, address) {
|
|
162
172
|
return verify(messageToHash(message), signature, address);
|
|
163
173
|
}
|
package/es/utils/crypto.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.mjs","names":["nacl","_blakejsBlake2bJs","blake2b","_varuintBitcoin","encode","varuintEncode","concatBuffers","decode","Encoding","getAddressFromPriv","secret","secretBuffer","_Buffer","from","keys","sign","keyPair","fromSecretKey","publicKey","AccountAddress","isAddressValid","address","prefix","arguments","length","undefined","e","genSalt","random","BigUint64Array","randomBytes","buffer","Number","BigInt","MAX_SAFE_INTEGER","encodeUnsigned","value","binary","allocUnsafe","writeUInt32BE","slice","findIndex","i","hash","input","encodeContractAddress","owner","nonce","ContractAddress","generateKeyPairFromSecret","generateKeyPair","raw","publicBuffer","secretKey","toString","data","privateKey","detached","verify","signature","messageToHash","message","p","msg","signMessage","verifyMessage","isValidKeypair","publicKeyBuffer"],"sources":["../../src/utils/crypto.ts"],"sourcesContent":["import nacl, { SignKeyPair } 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 } from './other';\nimport {\n decode, encode, Encoded, Encoding,\n} from './encoder';\n\n/**\n * Generate address from secret key\n * @param secret - Private key as hex string\n * @returns Public key encoded as address\n */\nexport function getAddressFromPriv(secret: string | Uint8Array): Encoded.AccountAddress {\n const secretBuffer = typeof secret === 'string' ? Buffer.from(secret, 'hex') : secret;\n const keys = nacl.sign.keyPair.fromSecretKey(secretBuffer);\n return encode(keys.publicKey, Encoding.AccountAddress);\n}\n\n/**\n * Check if address is valid\n * @param address - Address\n * @param prefix - Transaction prefix. Default: 'ak'\n * @returns is valid\n */\nexport function isAddressValid(\n address: string,\n prefix: Encoding = Encoding.AccountAddress,\n): boolean {\n try {\n decode(address as Encoded.Generic<typeof prefix>);\n return true;\n } catch (e) {\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// KEY-PAIR HELPERS\n\n/**\n * Generate keyPair from secret key\n * @param secret - secret key\n * @returns Object with Private(privateKey) and Public(publicKey) keys\n */\nexport function generateKeyPairFromSecret(secret: Uint8Array): SignKeyPair {\n return nacl.sign.keyPair.fromSecretKey(secret);\n}\n\n/**\n * Generate a random ED25519 keypair\n * @param raw - Whether to return raw (binary) keys\n * @returns Key pair\n */\nexport function generateKeyPair(raw: true): { publicKey: Buffer; secretKey: Buffer };\nexport function generateKeyPair(raw?: false): {\n publicKey: Encoded.AccountAddress; secretKey: string;\n};\nexport function generateKeyPair(raw = false): {\n publicKey: Encoded.AccountAddress | Buffer;\n secretKey: string | Buffer;\n} {\n const keyPair = nacl.sign.keyPair();\n const publicBuffer = Buffer.from(keyPair.publicKey);\n const secretBuffer = Buffer.from(keyPair.secretKey);\n\n if (raw) {\n return {\n publicKey: publicBuffer,\n secretKey: secretBuffer,\n };\n }\n return {\n publicKey: encode(publicBuffer, Encoding.AccountAddress),\n secretKey: secretBuffer.toString('hex'),\n };\n}\n\n// SIGNATURES\n\n/**\n * Generate signature\n * @param data - Data to sign\n * @param privateKey - Key to sign with\n * @returns Signature\n */\nexport function sign(data: string | Uint8Array, privateKey: string | Uint8Array): Uint8Array {\n return nacl.sign.detached(Buffer.from(data), Buffer.from(privateKey));\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\nexport function messageToHash(message: string): Buffer {\n const p = Buffer.from('aeternity Signed Message:\\n', 'utf8');\n const msg = Buffer.from(message, 'utf8');\n return hash(concatBuffers([varuintEncode(p.length), p, varuintEncode(msg.length), msg]));\n}\n\nexport function signMessage(message: string, privateKey: string | Buffer): Uint8Array {\n return sign(messageToHash(message), privateKey);\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 */\nexport function verifyMessage(\n message: string,\n signature: Uint8Array,\n address: Encoded.AccountAddress,\n): boolean {\n return verify(messageToHash(message), signature, address);\n}\n\n/**\n * Check key pair for validity\n *\n * Sign a message, and then verifying that signature\n * @param privateKey - Private key to verify\n * @param publicKey - Public key to verify as hex string\n * @returns Valid?\n */\nexport function isValidKeypair(\n privateKey: string | Uint8Array,\n publicKey: string | Uint8Array,\n): boolean {\n const message = Buffer.from('TheMessage');\n const signature = sign(message, privateKey);\n const publicKeyBuffer = typeof publicKey === 'string' ? Buffer.from(publicKey, 'hex') : publicKey;\n return verify(message, signature, encode(publicKeyBuffer, Encoding.AccountAddress));\n}\n"],"mappings":";;;;AAAA,OAAOA,IAAI,MAAuB,WAAW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AEA,OAAO,SAASC,WAAWA,CAACH,OAAe,EAAEL,UAA2B,EAAc;EACpF,OAAOzC,IAAI,CAAC6C,aAAa,CAACC,OAAO,CAAC,EAAEL,UAAU,CAAC;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,aAAaA,CAC3BJ,OAAe,EACfF,SAAqB,EACrBtC,OAA+B,EACtB;EACT,OAAOqC,MAAM,CAACE,aAAa,CAACC,OAAO,CAAC,EAAEF,SAAS,EAAEtC,OAAO,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS6C,cAAcA,CAC5BV,UAA+B,EAC/BtC,SAA8B,EACrB;EACT,MAAM2C,OAAO,GAAGjD,OAAA,CAAOC,IAAI,CAAC,YAAY,CAAC;EACzC,MAAM8C,SAAS,GAAG5C,IAAI,CAAC8C,OAAO,EAAEL,UAAU,CAAC;EAC3C,MAAMW,eAAe,GAAG,OAAOjD,SAAS,KAAK,QAAQ,GAAGN,OAAA,CAAOC,IAAI,CAACK,SAAS,EAAE,KAAK,CAAC,GAAGA,SAAS;EACjG,OAAOwC,MAAM,CAACG,OAAO,EAAEF,SAAS,EAAEvD,MAAM,CAAC+D,eAAe,EAAE3D,QAAQ,CAACW,cAAc,CAAC,CAAC;AACrF"}
|
|
1
|
+
{"version":3,"file":"crypto.mjs","names":["nacl","_blakejsBlake2bJs","blake2b","_varuintBitcoin","encode","varuintEncode","concatBuffers","decode","Encoding","ArgumentError","getAddressFromPriv","secret","secretBuffer","_Buffer","from","keys","sign","keyPair","fromSecretKey","publicKey","AccountAddress","isAddressValid","address","prefix","arguments","length","undefined","actualPrefix","split","e","genSalt","random","BigUint64Array","randomBytes","buffer","Number","BigInt","MAX_SAFE_INTEGER","encodeUnsigned","value","binary","allocUnsafe","writeUInt32BE","slice","findIndex","i","hash","input","encodeContractAddress","owner","nonce","ContractAddress","generateKeyPairFromSecret","generateKeyPair","raw","publicBuffer","secretKey","toString","data","privateKey","detached","verify","signature","messagePrefix","messagePrefixLength","messageToHash","message","msg","signMessage","verifyMessage","isValidKeypair","publicKeyBuffer"],"sources":["../../src/utils/crypto.ts"],"sourcesContent":["import nacl, { SignKeyPair } 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 } from './other';\nimport {\n decode, encode, Encoded, Encoding,\n} from './encoder';\nimport { ArgumentError } from './errors';\n\n/**\n * Generate address from secret key\n * @param secret - Private key as hex string\n * @returns Public key encoded as address\n */\nexport function getAddressFromPriv(secret: string | Uint8Array): Encoded.AccountAddress {\n const secretBuffer = typeof secret === 'string' ? Buffer.from(secret, 'hex') : secret;\n const keys = nacl.sign.keyPair.fromSecretKey(secretBuffer);\n return encode(keys.publicKey, Encoding.AccountAddress);\n}\n\n/**\n * Check if address is valid\n * @param address - Address\n * @param prefix - Transaction prefix. Default: 'ak'\n * @returns is valid\n */\nexport function isAddressValid(\n address: string,\n prefix: Encoding = Encoding.AccountAddress,\n): boolean {\n try {\n decode(address as Encoded.Generic<typeof prefix>);\n const actualPrefix = address.split('_')[0];\n if (actualPrefix !== prefix) {\n throw new ArgumentError('Encoded string type', prefix, actualPrefix);\n }\n return true;\n } catch (e) {\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// KEY-PAIR HELPERS\n\n/**\n * Generate keyPair from secret key\n * @param secret - secret key\n * @returns Object with Private(privateKey) and Public(publicKey) keys\n */\nexport function generateKeyPairFromSecret(secret: Uint8Array): SignKeyPair {\n return nacl.sign.keyPair.fromSecretKey(secret);\n}\n\n/**\n * Generate a random ED25519 keypair\n * @param raw - Whether to return raw (binary) keys\n * @returns Key pair\n */\nexport function generateKeyPair(raw: true): { publicKey: Buffer; secretKey: Buffer };\nexport function generateKeyPair(raw?: false): {\n publicKey: Encoded.AccountAddress; secretKey: string;\n};\nexport function generateKeyPair(raw = false): {\n publicKey: Encoded.AccountAddress | Buffer;\n secretKey: string | Buffer;\n} {\n const keyPair = nacl.sign.keyPair();\n const publicBuffer = Buffer.from(keyPair.publicKey);\n const secretBuffer = Buffer.from(keyPair.secretKey);\n\n if (raw) {\n return {\n publicKey: publicBuffer,\n secretKey: secretBuffer,\n };\n }\n return {\n publicKey: encode(publicBuffer, Encoding.AccountAddress),\n secretKey: secretBuffer.toString('hex'),\n };\n}\n\n// SIGNATURES\n\n/**\n * Generate signature\n * @param data - Data to sign\n * @param privateKey - Key to sign with\n * @returns Signature\n */\nexport function sign(data: string | Uint8Array, privateKey: string | Uint8Array): Uint8Array {\n return nacl.sign.detached(Buffer.from(data), Buffer.from(privateKey));\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);\n\n// TODO: consider rename to hashMessage\nexport function messageToHash(message: string): Buffer {\n const msg = Buffer.from(message, 'utf8');\n return hash(concatBuffers([messagePrefixLength, messagePrefix, varuintEncode(msg.length), msg]));\n}\n\nexport function signMessage(message: string, privateKey: string | Buffer): Uint8Array {\n return sign(messageToHash(message), privateKey);\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\n/**\n * Check key pair for validity\n *\n * Sign a message, and then verifying that signature\n * @param privateKey - Private key to verify\n * @param publicKey - Public key to verify as hex string\n * @returns Valid?\n */\nexport function isValidKeypair(\n privateKey: string | Uint8Array,\n publicKey: string | Uint8Array,\n): boolean {\n const message = Buffer.from('TheMessage');\n const signature = sign(message, privateKey);\n const publicKeyBuffer = typeof publicKey === 'string' ? Buffer.from(publicKey, 'hex') : publicKey;\n return verify(message, signature, encode(publicKeyBuffer, Encoding.AccountAddress));\n}\n"],"mappings":";;;;AAAA,OAAOA,IAAI,MAAuB,WAAW;AAC7C;AACA;AACA,OAAAC,iBAAA,MAAwB,oBAAoB;AAAC;EAAAC;AAAA,IAAAD,iBAAA;AAC7C,OAAAE,eAAA,MAAwC,iBAAiB;AAAC;EAAAC,MAAA,EAAAC;AAAA,IAAAF,eAAA;AAAA,SAEjDG,aAAa;AAAA,SAEpBC,MAAM,EAAEH,MAAM,EAAWI,QAAQ;AA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,CAAC,EAAE0C,GAAG,CAAC,CAAC,CAAC;AAClG;AAEA,OAAO,SAASC,WAAWA,CAACF,OAAe,EAAEP,UAA2B,EAAc;EACpF,OAAO3C,IAAI,CAACiD,aAAa,CAACC,OAAO,CAAC,EAAEP,UAAU,CAAC;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASU,aAAaA,CAC3BH,OAAe,EACfJ,SAAqB,EACrBxC,OAA+B,EACtB;EACT,OAAOuC,MAAM,CAACI,aAAa,CAACC,OAAO,CAAC,EAAEJ,SAAS,EAAExC,OAAO,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASgD,cAAcA,CAC5BX,UAA+B,EAC/BxC,SAA8B,EACrB;EACT,MAAM+C,OAAO,GAAGrD,OAAA,CAAOC,IAAI,CAAC,YAAY,CAAC;EACzC,MAAMgD,SAAS,GAAG9C,IAAI,CAACkD,OAAO,EAAEP,UAAU,CAAC;EAC3C,MAAMY,eAAe,GAAG,OAAOpD,SAAS,KAAK,QAAQ,GAAGN,OAAA,CAAOC,IAAI,CAACK,SAAS,EAAE,KAAK,CAAC,GAAGA,SAAS;EACjG,OAAO0C,MAAM,CAACK,OAAO,EAAEJ,SAAS,EAAE1D,MAAM,CAACmE,eAAe,EAAE/D,QAAQ,CAACY,cAAc,CAAC,CAAC;AACrF"}
|
package/es/utils/errors.d.ts
CHANGED
|
@@ -240,11 +240,11 @@ export declare class UnexpectedChannelMessageError extends ChannelError {
|
|
|
240
240
|
* @category exception
|
|
241
241
|
*/
|
|
242
242
|
export declare class ChannelIncomingMessageError extends ChannelError {
|
|
243
|
-
handlerError:
|
|
243
|
+
handlerError: Error;
|
|
244
244
|
incomingMessage: {
|
|
245
245
|
[key: string]: any;
|
|
246
246
|
};
|
|
247
|
-
constructor(handlerError:
|
|
247
|
+
constructor(handlerError: Error, incomingMessage: {
|
|
248
248
|
[key: string]: any;
|
|
249
249
|
});
|
|
250
250
|
}
|
package/es/utils/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","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","join","TypeError","UnsupportedPlatformError","UnsupportedProtocolError","NotImplementedError","UnsupportedVersionError","dependency","version","geVersion","ltVersion","InternalError","UnexpectedTsError","arguments","length","undefined","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","_ref","InvalidChecksumError","InvalidPasswordError","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';\nimport * as Encoded from './encoder-types';\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([\n `Giving up after ${blocks} blocks mined`,\n `transaction hash: ${th}`,\n ].join(', '));\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(`Unsupported ${dependency} version ${version}. Supported: >= ${geVersion} < ${ltVersion}`);\n this.name = 'UnsupportedVersionError';\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(`the provided fee ${nameFee.toString()} is not enough to execute the claim, required: ${minNameFee.toString()}`);\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: BaseError;\n\n incomingMessage: { [key: string]: any };\n\n constructor(handlerError: BaseError, 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 InvalidPasswordError extends CryptographyError {\n constructor() {\n super('Invalid password or nonce');\n this.name = 'InvalidPasswordError';\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,O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AC1B,KAAK,CAAE,qBAAoBA,MAAO,aAAY,CAAC;IAC/C,IAAI,CAAC/C,IAAI,GAAG,aAAa;EAC3B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAM+G,iBAAiB,SAAStG,gBAAgB,CAAC;EACtDX,WAAWA,CAACkH,MAAsB,EAAE;IAClC,KAAK,CAAE,eAAcA,MAAO,wBAAuB,CAAC;IACpD,IAAI,CAAChH,IAAI,GAAG,mBAAmB;EACjC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMiH,qBAAqB,SAASvG,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,MAAMkH,sBAAsB,SAASxG,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,MAAMmH,kBAAkB,SAASzG,WAAW,CAAC;EAClDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,oBAAoB;EAClC;AACF"}
|
|
1
|
+
{"version":3,"file":"errors.mjs","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","join","TypeError","UnsupportedPlatformError","UnsupportedProtocolError","NotImplementedError","UnsupportedVersionError","dependency","version","geVersion","ltVersion","InternalError","UnexpectedTsError","arguments","length","undefined","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","_ref","InvalidChecksumError","InvalidPasswordError","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';\nimport * as Encoded from './encoder-types';\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([\n `Giving up after ${blocks} blocks mined`,\n `transaction hash: ${th}`,\n ].join(', '));\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(`Unsupported ${dependency} version ${version}. Supported: >= ${geVersion} < ${ltVersion}`);\n this.name = 'UnsupportedVersionError';\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(`the provided fee ${nameFee.toString()} is not enough to execute the claim, required: ${minNameFee.toString()}`);\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 InvalidPasswordError extends CryptographyError {\n constructor() {\n super('Invalid password or nonce');\n this.name = 'InvalidPasswordError';\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;EAC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A;AACA;AACA;AACA,OAAO,MAAMkH,sBAAsB,SAASxG,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,MAAMmH,kBAAkB,SAASzG,WAAW,CAAC;EAClDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,oBAAoB;EAClC;AACF"}
|
package/es/utils/other.d.ts
CHANGED
|
@@ -20,3 +20,4 @@ export declare function isKeyOfObject<T extends object>(key: string | number | s
|
|
|
20
20
|
export declare function isItemOfArray<T>(item: any, array: readonly T[]): item is T;
|
|
21
21
|
export declare function isAccountNotFoundError(error: Error): boolean;
|
|
22
22
|
export type UnionToIntersection<Union> = (Union extends any ? (k: Union) => void : never) extends ((k: infer Intersection) => void) ? Intersection : never;
|
|
23
|
+
export declare function ensureError(error: unknown): asserts error is Error;
|
package/es/utils/other.mjs
CHANGED
package/es/utils/other.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"other.mjs","names":["RestError","pause","duration","Promise","resolve","setTimeout","mapObject","object","fn","Object","fromEntries","entries","map","isWebpack4Buffer","_Buffer","concat","Uint8Array","from","error","concatBuffers","list","totalLength","el","isKeyOfObject","key","isItemOfArray","item","array","includes","isAccountNotFoundError","statusCode","message"],"sources":["../../src/utils/other.ts"],"sourcesContent":["import { RestError } from '@azure/core-rest-pipeline';\n\nexport const pause = async (duration: number): Promise<void> => new Promise((resolve) => {\n setTimeout(resolve, duration);\n});\n\nexport const mapObject = <InputV, OutputV>(\n object: { [k: string]: InputV },\n fn: (\n value: [string, InputV], index: number, array: Array<[string, InputV]>\n ) => [number | string, OutputV],\n): { [k: string]: OutputV } => Object.fromEntries(Object.entries(object).map(fn));\n\n// remove after dropping webpack4 support\nconst isWebpack4Buffer = (() => {\n try {\n Buffer.concat([Uint8Array.from([])]);\n return false;\n } catch (error) {\n return true;\n }\n})();\n\nexport const concatBuffers = isWebpack4Buffer\n ? (list: readonly Uint8Array[], totalLength?: number): Buffer => (\n Buffer.concat(list.map((el) => Buffer.from(el)), totalLength)\n )\n : Buffer.concat;\n\n/**\n * Object key type guard\n * @param key - Maybe object key\n * @param object - Object\n */\nexport function isKeyOfObject<T extends object>(\n key: string | number | symbol,\n object: T,\n): key is keyof T {\n return key in object;\n}\n\n/**\n * Array item type guard\n * @param item - Maybe array item\n * @param array - Array\n */\nexport function isItemOfArray<T>(item: any, array: readonly T[]): item is T {\n return array.includes(item);\n}\n\nexport function isAccountNotFoundError(error: Error): boolean {\n return error instanceof RestError && error.statusCode === 404\n && error.message.includes('Account not found');\n}\n\n// based on https://stackoverflow.com/a/50375286/6176994\nexport type UnionToIntersection<Union> =\n (Union extends any ? (k: Union) => void : never) extends ((k: infer Intersection) => void)\n ? Intersection : never;\n"],"mappings":";;;;AAAA,SAASA,SAAS,QAAQ,2BAA2B;AAErD,OAAO,MAAMC,KAAK,GAAG,MAAOC,QAAgB,IAAoB,IAAIC,OAAO,CAAEC,OAAO,IAAK;EACvFC,UAAU,CAACD,OAAO,EAAEF,QAAQ,CAAC;AAC/B,CAAC,CAAC;AAEF,OAAO,MAAMI,SAAS,GAAGA,CACvBC,MAA+B,EAC/BC,EAE+B,KACFC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACJ,MAAM,CAAC,CAACK,GAAG,CAACJ,EAAE,CAAC,CAAC;;AAEjF;AACA,MAAMK,gBAAgB,GAAG,CAAC,MAAM;EAC9B,IAAI;IACFC,OAAA,CAAOC,MAAM,CAAC,CAACC,UAAU,CAACC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,OAAO,KAAK;EACd,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,OAAO,IAAI;EACb;AACF,CAAC,GAAG;AAEJ,OAAO,MAAMC,aAAa,GAAGN,gBAAgB,GACzC,CAACO,IAA2B,EAAEC,WAAoB,KAClDP,OAAA,CAAOC,MAAM,CAACK,IAAI,CAACR,GAAG,CAAEU,EAAE,IAAKR,OAAA,CAAOG,IAAI,CAACK,EAAE,CAAC,CAAC,EAAED,WAAW,CAC7D,GACCP,OAAA,CAAOC,MAAM;;AAEjB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,aAAaA,CAC3BC,GAA6B,EAC7BjB,MAAS,EACO;EAChB,OAAOiB,GAAG,IAAIjB,MAAM;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASkB,aAAaA,CAAIC,IAAS,EAAEC,KAAmB,EAAa;EAC1E,OAAOA,KAAK,CAACC,QAAQ,CAACF,IAAI,CAAC;AAC7B;AAEA,OAAO,SAASG,sBAAsBA,CAACX,KAAY,EAAW;EAC5D,OAAOA,KAAK,YAAYlB,SAAS,IAAIkB,KAAK,CAACY,UAAU,KAAK,GAAG,IACxDZ,KAAK,CAACa,OAAO,CAACH,QAAQ,CAAC,mBAAmB,CAAC;AAClD;;AAEA"}
|
|
1
|
+
{"version":3,"file":"other.mjs","names":["RestError","pause","duration","Promise","resolve","setTimeout","mapObject","object","fn","Object","fromEntries","entries","map","isWebpack4Buffer","_Buffer","concat","Uint8Array","from","error","concatBuffers","list","totalLength","el","isKeyOfObject","key","isItemOfArray","item","array","includes","isAccountNotFoundError","statusCode","message","ensureError","Error"],"sources":["../../src/utils/other.ts"],"sourcesContent":["import { RestError } from '@azure/core-rest-pipeline';\n\nexport const pause = async (duration: number): Promise<void> => new Promise((resolve) => {\n setTimeout(resolve, duration);\n});\n\nexport const mapObject = <InputV, OutputV>(\n object: { [k: string]: InputV },\n fn: (\n value: [string, InputV], index: number, array: Array<[string, InputV]>\n ) => [number | string, OutputV],\n): { [k: string]: OutputV } => Object.fromEntries(Object.entries(object).map(fn));\n\n// remove after dropping webpack4 support\nconst isWebpack4Buffer = (() => {\n try {\n Buffer.concat([Uint8Array.from([])]);\n return false;\n } catch (error) {\n return true;\n }\n})();\n\nexport const concatBuffers = isWebpack4Buffer\n ? (list: readonly Uint8Array[], totalLength?: number): Buffer => (\n Buffer.concat(list.map((el) => Buffer.from(el)), totalLength)\n )\n : Buffer.concat;\n\n/**\n * Object key type guard\n * @param key - Maybe object key\n * @param object - Object\n */\nexport function isKeyOfObject<T extends object>(\n key: string | number | symbol,\n object: T,\n): key is keyof T {\n return key in object;\n}\n\n/**\n * Array item type guard\n * @param item - Maybe array item\n * @param array - Array\n */\nexport function isItemOfArray<T>(item: any, array: readonly T[]): item is T {\n return array.includes(item);\n}\n\nexport function isAccountNotFoundError(error: Error): boolean {\n return error instanceof RestError && error.statusCode === 404\n && error.message.includes('Account not found');\n}\n\n// based on https://stackoverflow.com/a/50375286/6176994\nexport type UnionToIntersection<Union> =\n (Union extends any ? (k: Union) => void : never) extends ((k: infer Intersection) => void)\n ? Intersection : never;\n\nexport function ensureError(error: unknown): asserts error is Error {\n if (error instanceof Error) return;\n throw error;\n}\n"],"mappings":";;;;AAAA,SAASA,SAAS,QAAQ,2BAA2B;AAErD,OAAO,MAAMC,KAAK,GAAG,MAAOC,QAAgB,IAAoB,IAAIC,OAAO,CAAEC,OAAO,IAAK;EACvFC,UAAU,CAACD,OAAO,EAAEF,QAAQ,CAAC;AAC/B,CAAC,CAAC;AAEF,OAAO,MAAMI,SAAS,GAAGA,CACvBC,MAA+B,EAC/BC,EAE+B,KACFC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACJ,MAAM,CAAC,CAACK,GAAG,CAACJ,EAAE,CAAC,CAAC;;AAEjF;AACA,MAAMK,gBAAgB,GAAG,CAAC,MAAM;EAC9B,IAAI;IACFC,OAAA,CAAOC,MAAM,CAAC,CAACC,UAAU,CAACC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,OAAO,KAAK;EACd,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,OAAO,IAAI;EACb;AACF,CAAC,GAAG;AAEJ,OAAO,MAAMC,aAAa,GAAGN,gBAAgB,GACzC,CAACO,IAA2B,EAAEC,WAAoB,KAClDP,OAAA,CAAOC,MAAM,CAACK,IAAI,CAACR,GAAG,CAAEU,EAAE,IAAKR,OAAA,CAAOG,IAAI,CAACK,EAAE,CAAC,CAAC,EAAED,WAAW,CAC7D,GACCP,OAAA,CAAOC,MAAM;;AAEjB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,aAAaA,CAC3BC,GAA6B,EAC7BjB,MAAS,EACO;EAChB,OAAOiB,GAAG,IAAIjB,MAAM;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASkB,aAAaA,CAAIC,IAAS,EAAEC,KAAmB,EAAa;EAC1E,OAAOA,KAAK,CAACC,QAAQ,CAACF,IAAI,CAAC;AAC7B;AAEA,OAAO,SAASG,sBAAsBA,CAACX,KAAY,EAAW;EAC5D,OAAOA,KAAK,YAAYlB,SAAS,IAAIkB,KAAK,CAACY,UAAU,KAAK,GAAG,IACxDZ,KAAK,CAACa,OAAO,CAACH,QAAQ,CAAC,mBAAmB,CAAC;AAClD;;AAEA;;AAKA,OAAO,SAASI,WAAWA,CAACd,KAAc,EAA0B;EAClE,IAAIA,KAAK,YAAYe,KAAK,EAAE;EAC5B,MAAMf,KAAK;AACb"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Encoded } from './encoder';
|
|
3
|
+
/**
|
|
4
|
+
* Hashes arbitrary object, can be used to inline the aci hash to contract source code
|
|
5
|
+
*/
|
|
6
|
+
export declare function hashJson(data: unknown): Buffer;
|
|
7
|
+
export type AciValue = 'void' | 'unit' | 'int' | 'bool' | 'string' | 'bits' | 'hash' | 'signature' | 'address' | 'contract_pubkey' | 'Chain.ttl' | 'Chain.ga_meta_tx' | 'Chain.paying_for_tx' | 'Chain.base_tx' | 'AENS.pointee' | 'AENS.name' | 'MCL_BLS12_381.fr' | 'MCL_BLS12_381.fp' | {
|
|
8
|
+
'Set.set': readonly [AciValue];
|
|
9
|
+
} | {
|
|
10
|
+
bytes: number;
|
|
11
|
+
} | {
|
|
12
|
+
list: readonly [AciValue];
|
|
13
|
+
} | {
|
|
14
|
+
map: readonly [AciValue, AciValue];
|
|
15
|
+
} | {
|
|
16
|
+
tuple: readonly AciValue[];
|
|
17
|
+
} | {
|
|
18
|
+
record: ReadonlyArray<{
|
|
19
|
+
name: string;
|
|
20
|
+
type: AciValue;
|
|
21
|
+
}>;
|
|
22
|
+
} | {
|
|
23
|
+
variant: ReadonlyArray<{
|
|
24
|
+
[key: string]: readonly AciValue[];
|
|
25
|
+
}>;
|
|
26
|
+
} | {
|
|
27
|
+
option: readonly [AciValue];
|
|
28
|
+
} | {
|
|
29
|
+
oracle: readonly [AciValue, AciValue];
|
|
30
|
+
} | {
|
|
31
|
+
oracle_query: readonly [AciValue, AciValue];
|
|
32
|
+
};
|
|
33
|
+
export interface Domain {
|
|
34
|
+
name?: string;
|
|
35
|
+
version?: number;
|
|
36
|
+
networkId?: string;
|
|
37
|
+
contractAddress?: Encoded.ContractAddress;
|
|
38
|
+
}
|
|
39
|
+
export declare function encodeFateValue(value: unknown, aci: AciValue): Encoded.ContractBytearray;
|
|
40
|
+
export declare function decodeFateValue(value: Encoded.ContractBytearray, aci: AciValue): Encoded.ContractBytearray;
|
|
41
|
+
/**
|
|
42
|
+
* Hashes domain object, can be used to inline domain hash to contract source code
|
|
43
|
+
*/
|
|
44
|
+
export declare function hashDomain(domain: Domain): Buffer;
|
|
45
|
+
export declare function hashTypedData(data: Encoded.ContractBytearray, aci: AciValue, domain: Domain): Buffer;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// js extension is required for mjs build
|
|
2
|
+
// @ts-expect-error see https://github.com/aeternity/aepp-calldata-js/issues/216
|
|
3
|
+
// eslint-disable-next-line import/extensions
|
|
4
|
+
import ContractByteArrayEncoder from '@aeternity/aepp-calldata/src/ContractByteArrayEncoder.js';
|
|
5
|
+
// @ts-expect-error see https://github.com/aeternity/aepp-calldata-js/issues/216
|
|
6
|
+
// eslint-disable-next-line import/extensions
|
|
7
|
+
import AciTypeResolver from '@aeternity/aepp-calldata/src/AciTypeResolver.js';
|
|
8
|
+
import canonicalize from 'canonicalize';
|
|
9
|
+
import { decode } from "./encoder.mjs";
|
|
10
|
+
import { hash, messagePrefixLength } from "./crypto.mjs";
|
|
11
|
+
import { concatBuffers } from "./other.mjs";
|
|
12
|
+
/**
|
|
13
|
+
* Hashes arbitrary object, can be used to inline the aci hash to contract source code
|
|
14
|
+
*/
|
|
15
|
+
export function hashJson(data) {
|
|
16
|
+
var _canonicalize;
|
|
17
|
+
return hash((_canonicalize = canonicalize(data)) !== null && _canonicalize !== void 0 ? _canonicalize : '');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// TODO: move this type to calldata library https://github.com/aeternity/aepp-calldata-js/issues/215
|
|
21
|
+
// based on https://github.com/aeternity/aepp-calldata-js/blob/82b5a98f9b308482627da8d7484d213e9cf87151/src/AciTypeResolver.js#L129
|
|
22
|
+
|
|
23
|
+
// TODO: replace with api on calldata side https://github.com/aeternity/aepp-calldata-js/issues/216
|
|
24
|
+
export function encodeFateValue(value, aci) {
|
|
25
|
+
const contractByteArrayEncoder = new ContractByteArrayEncoder();
|
|
26
|
+
const aciTypeResolver = new AciTypeResolver([]);
|
|
27
|
+
aciTypeResolver.isCustomType = () => false;
|
|
28
|
+
return contractByteArrayEncoder.encode(aciTypeResolver.resolveType(aci), value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// TODO: replace with api on calldata side https://github.com/aeternity/aepp-calldata-js/issues/216
|
|
32
|
+
export function decodeFateValue(value, aci) {
|
|
33
|
+
const contractByteArrayEncoder = new ContractByteArrayEncoder();
|
|
34
|
+
const aciTypeResolver = new AciTypeResolver([]);
|
|
35
|
+
aciTypeResolver.isCustomType = () => false;
|
|
36
|
+
return contractByteArrayEncoder.decodeWithType(value, aciTypeResolver.resolveType(aci));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Hashes domain object, can be used to inline domain hash to contract source code
|
|
41
|
+
*/
|
|
42
|
+
export function hashDomain(domain) {
|
|
43
|
+
const domainAci = {
|
|
44
|
+
record: [{
|
|
45
|
+
name: 'name',
|
|
46
|
+
type: {
|
|
47
|
+
option: ['string']
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
name: 'version',
|
|
51
|
+
type: {
|
|
52
|
+
option: ['int']
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
name: 'networkId',
|
|
56
|
+
type: {
|
|
57
|
+
option: ['string']
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
name: 'contractAddress',
|
|
61
|
+
type: {
|
|
62
|
+
option: ['contract_pubkey']
|
|
63
|
+
}
|
|
64
|
+
}]
|
|
65
|
+
};
|
|
66
|
+
return hash(decode(encodeFateValue(domain, domainAci)));
|
|
67
|
+
}
|
|
68
|
+
export function hashTypedData(data, aci, domain) {
|
|
69
|
+
return hash(concatBuffers([messagePrefixLength, new Uint8Array([0]), hashDomain(domain), hashJson(aci), hash(decode(data))]));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=typed-data.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-data.mjs","names":["ContractByteArrayEncoder","AciTypeResolver","canonicalize","decode","hash","messagePrefixLength","concatBuffers","hashJson","data","_canonicalize","encodeFateValue","value","aci","contractByteArrayEncoder","aciTypeResolver","isCustomType","encode","resolveType","decodeFateValue","decodeWithType","hashDomain","domain","domainAci","record","name","type","option","hashTypedData","Uint8Array"],"sources":["../../src/utils/typed-data.ts"],"sourcesContent":["// js extension is required for mjs build\n// @ts-expect-error see https://github.com/aeternity/aepp-calldata-js/issues/216\n// eslint-disable-next-line import/extensions\nimport ContractByteArrayEncoder from '@aeternity/aepp-calldata/src/ContractByteArrayEncoder.js';\n// @ts-expect-error see https://github.com/aeternity/aepp-calldata-js/issues/216\n// eslint-disable-next-line import/extensions\nimport AciTypeResolver from '@aeternity/aepp-calldata/src/AciTypeResolver.js';\nimport canonicalize from 'canonicalize';\nimport { Encoded, decode } from './encoder';\nimport { hash, messagePrefixLength } from './crypto';\nimport { concatBuffers } from './other';\n\n/**\n * Hashes arbitrary object, can be used to inline the aci hash to contract source code\n */\nexport function hashJson(data: unknown): Buffer {\n return hash(canonicalize(data) ?? '');\n}\n\n// TODO: move this type to calldata library https://github.com/aeternity/aepp-calldata-js/issues/215\n// based on https://github.com/aeternity/aepp-calldata-js/blob/82b5a98f9b308482627da8d7484d213e9cf87151/src/AciTypeResolver.js#L129\nexport type AciValue = 'void' | 'unit' | 'int' | 'bool' | 'string' | 'bits' | 'hash' | 'signature'\n| 'address' | 'contract_pubkey' | 'Chain.ttl' | 'Chain.ga_meta_tx' | 'Chain.paying_for_tx'\n| 'Chain.base_tx' | 'AENS.pointee' | 'AENS.name' | 'MCL_BLS12_381.fr' | 'MCL_BLS12_381.fp'\n| { 'Set.set': readonly [AciValue] }\n| { bytes: number }\n| { list: readonly [AciValue] }\n| { map: readonly [AciValue, AciValue] }\n| { tuple: readonly AciValue[] }\n| { record: ReadonlyArray<{ name: string; type: AciValue }> }\n| { variant: ReadonlyArray<{ [key: string]: readonly AciValue[] }> }\n| { option: readonly [AciValue] }\n| { oracle: readonly [AciValue, AciValue] }\n| { oracle_query: readonly [AciValue, AciValue] };\n\nexport interface Domain {\n name?: string;\n version?: number;\n networkId?: string;\n contractAddress?: Encoded.ContractAddress;\n}\n\n// TODO: replace with api on calldata side https://github.com/aeternity/aepp-calldata-js/issues/216\nexport function encodeFateValue(\n value: unknown,\n aci: AciValue,\n): Encoded.ContractBytearray {\n const contractByteArrayEncoder = new ContractByteArrayEncoder();\n const aciTypeResolver = new AciTypeResolver([]);\n aciTypeResolver.isCustomType = () => false;\n return contractByteArrayEncoder.encode(aciTypeResolver.resolveType(aci), value);\n}\n\n// TODO: replace with api on calldata side https://github.com/aeternity/aepp-calldata-js/issues/216\nexport function decodeFateValue(\n value: Encoded.ContractBytearray,\n aci: AciValue,\n): Encoded.ContractBytearray {\n const contractByteArrayEncoder = new ContractByteArrayEncoder();\n const aciTypeResolver = new AciTypeResolver([]);\n aciTypeResolver.isCustomType = () => false;\n return contractByteArrayEncoder.decodeWithType(value, aciTypeResolver.resolveType(aci));\n}\n\n/**\n * Hashes domain object, can be used to inline domain hash to contract source code\n */\nexport function hashDomain(domain: Domain): Buffer {\n const domainAci = {\n record: [{\n name: 'name',\n type: { option: ['string'] },\n }, {\n name: 'version',\n type: { option: ['int'] },\n }, {\n name: 'networkId',\n type: { option: ['string'] },\n }, {\n name: 'contractAddress',\n type: { option: ['contract_pubkey'] },\n }],\n } as const;\n return hash(decode(encodeFateValue(domain, domainAci)));\n}\n\nexport function hashTypedData(\n data: Encoded.ContractBytearray,\n aci: AciValue,\n domain: Domain,\n): Buffer {\n return hash(concatBuffers([\n messagePrefixLength, new Uint8Array([0]), hashDomain(domain), hashJson(aci), hash(decode(data)),\n ]));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,wBAAwB,MAAM,0DAA0D;AAC/F;AACA;AACA,OAAOC,eAAe,MAAM,iDAAiD;AAC7E,OAAOC,YAAY,MAAM,cAAc;AAAC,SACtBC,MAAM;AAAA,SACfC,IAAI,EAAEC,mBAAmB;AAAA,SACzBC,aAAa;AAEtB;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAACC,IAAa,EAAU;EAAA,IAAAC,aAAA;EAC9C,OAAOL,IAAI,EAAAK,aAAA,GAACP,YAAY,CAACM,IAAI,CAAC,cAAAC,aAAA,cAAAA,aAAA,GAAI,EAAE,CAAC;AACvC;;AAEA;AACA;;AAsBA;AACA,OAAO,SAASC,eAAeA,CAC7BC,KAAc,EACdC,GAAa,EACc;EAC3B,MAAMC,wBAAwB,GAAG,IAAIb,wBAAwB,EAAE;EAC/D,MAAMc,eA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ACxBD,mBAAmB,EAAE,IAAIuB,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAER,UAAU,CAACC,MAAM,CAAC,EAAEd,QAAQ,CAACK,GAAG,CAAC,EAAER,IAAI,CAACD,MAAM,CAACK,IAAI,CAAC,CAAC,CAChG,CAAC,CAAC;AACL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeternity/aepp-sdk",
|
|
3
|
-
"version": "13.0
|
|
3
|
+
"version": "13.1.0",
|
|
4
4
|
"description": "SDK for the æternity blockchain",
|
|
5
5
|
"main": "dist/aepp-sdk.js",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
@@ -8,11 +8,17 @@
|
|
|
8
8
|
"<4.5": {
|
|
9
9
|
"es/index.d.ts": [
|
|
10
10
|
"./types-legacy/ts4.2/index.d.ts"
|
|
11
|
+
],
|
|
12
|
+
"es/index-browser.d.ts": [
|
|
13
|
+
"./types-legacy/ts4.2/index-browser.d.ts"
|
|
11
14
|
]
|
|
12
15
|
},
|
|
13
16
|
"<4.7": {
|
|
14
17
|
"es/index.d.ts": [
|
|
15
18
|
"./types-legacy/ts4.5/index.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"es/index-browser.d.ts": [
|
|
21
|
+
"./types-legacy/ts4.5/index-browser.d.ts"
|
|
16
22
|
]
|
|
17
23
|
}
|
|
18
24
|
},
|
|
@@ -23,9 +29,15 @@
|
|
|
23
29
|
},
|
|
24
30
|
"exports": {
|
|
25
31
|
"node": {
|
|
32
|
+
"types@<4.5": "./types-legacy/ts4.2/index.d.ts",
|
|
33
|
+
"types@<4.7": "./types-legacy/ts4.5/index.d.ts",
|
|
34
|
+
"types": "./es/index.d.ts",
|
|
26
35
|
"import": "./es/index.mjs",
|
|
27
36
|
"default": "./dist/aepp-sdk.js"
|
|
28
37
|
},
|
|
38
|
+
"types@<4.5": "./types-legacy/ts4.2/index-browser.d.ts",
|
|
39
|
+
"types@<4.7": "./types-legacy/ts4.5/index-browser.d.ts",
|
|
40
|
+
"types": "./es/index-browser.d.ts",
|
|
29
41
|
"import": "./es/index-browser.mjs",
|
|
30
42
|
"default": "./dist/aepp-sdk.browser.js"
|
|
31
43
|
},
|
|
@@ -34,7 +46,10 @@
|
|
|
34
46
|
"build:assets": "node tooling/fetch-aesophia-cli.mjs",
|
|
35
47
|
"build:types": "tsc && node tooling/downlevel/run.mjs",
|
|
36
48
|
"build:es": "babel src --config-file ./babel.esm.config.js --out-dir es --extensions .js,.ts --out-file-extension .mjs --source-maps true",
|
|
37
|
-
"build:api": "
|
|
49
|
+
"build:api:node": "autorest tooling/autorest/node.yaml",
|
|
50
|
+
"build:api:compiler": "node tooling/autorest/compiler-prepare.mjs && autorest tooling/autorest/compiler.yaml",
|
|
51
|
+
"build:api:middleware": "node tooling/autorest/middleware-prepare.mjs && autorest tooling/autorest/middleware.yaml",
|
|
52
|
+
"build:api": "npm run build:api:node && npm run build:api:compiler && npm run build:api:middleware",
|
|
38
53
|
"build:generate": "ts-node --transpileOnly tooling/generate-schema.ts",
|
|
39
54
|
"build": "npm run build:api && npm run build:generate && webpack && npm run build:types && npm run build:es && npm run build:assets",
|
|
40
55
|
"docs:examples": "node tooling/docs/examples-to-md.js examples/node/*.mjs",
|
|
@@ -47,7 +62,7 @@
|
|
|
47
62
|
"test:unit": "mocha './test/unit/'",
|
|
48
63
|
"test:watch": "mocha './test/unit/' './test/integration/' --watch",
|
|
49
64
|
"prepare": "npm run build",
|
|
50
|
-
"prepublishOnly": "test/examples.sh
|
|
65
|
+
"prepublishOnly": "test/examples.sh",
|
|
51
66
|
"release": "standard-version --skip.tag --infile docs/CHANGELOG.md",
|
|
52
67
|
"release-alpha": "npm run release -- --prerelease alpha",
|
|
53
68
|
"release-beta": "npm run release -- --prerelease beta"
|
|
@@ -74,13 +89,16 @@
|
|
|
74
89
|
"@types/uuid": "^9.0.1",
|
|
75
90
|
"@types/webextension-polyfill": "^0.10.0",
|
|
76
91
|
"@types/websocket": "^1.0.5",
|
|
92
|
+
"@types/ws": "^8.5.4",
|
|
77
93
|
"aes-js": "^3.1.2",
|
|
78
94
|
"bignumber.js": "^9.1.1",
|
|
79
95
|
"bip32-path": "^0.4.2",
|
|
80
96
|
"blakejs": "^1.2.1",
|
|
81
97
|
"bs58": "^5.0.0",
|
|
82
98
|
"buffer": "^6.0.3",
|
|
99
|
+
"canonicalize": "^2.0.0",
|
|
83
100
|
"events": "^3.3.0",
|
|
101
|
+
"isomorphic-ws": "^5.0.0",
|
|
84
102
|
"json-bigint": "^1.0.0",
|
|
85
103
|
"process": "^0.11.10",
|
|
86
104
|
"rlp": "^3.0.0",
|
|
@@ -88,7 +106,8 @@
|
|
|
88
106
|
"tweetnacl": "^1.0.3",
|
|
89
107
|
"tweetnacl-auth": "^1.0.1",
|
|
90
108
|
"varuint-bitcoin": "^1.1.2",
|
|
91
|
-
"websocket": "^1.0.34"
|
|
109
|
+
"websocket": "^1.0.34",
|
|
110
|
+
"ws": "^8.13.0"
|
|
92
111
|
},
|
|
93
112
|
"repository": {
|
|
94
113
|
"type": "git",
|
package/src/AeSdkBase.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import Node from './Node';
|
|
2
2
|
import AccountBase from './account/Base';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
CompilerError, DuplicateNodeError, NodeNotFoundError, NotImplementedError, TypeError,
|
|
5
|
+
} from './utils/errors';
|
|
4
6
|
import { Encoded } from './utils/encoder';
|
|
5
7
|
import CompilerBase from './contract/compiler/Base';
|
|
6
|
-
import AeSdkMethods, { OnAccount, getValueOrErrorProxy } from './AeSdkMethods';
|
|
8
|
+
import AeSdkMethods, { OnAccount, getValueOrErrorProxy, AeSdkMethodsOptions } from './AeSdkMethods';
|
|
7
9
|
|
|
8
10
|
type NodeInfo = Awaited<ReturnType<Node['getNodeInfo']>> & { name: string };
|
|
9
11
|
|
|
@@ -23,7 +25,7 @@ export default class AeSdkBase extends AeSdkMethods {
|
|
|
23
25
|
* @param options.nodes - Array of nodes
|
|
24
26
|
*/
|
|
25
27
|
constructor(
|
|
26
|
-
{ nodes = [], ...options }:
|
|
28
|
+
{ nodes = [], ...options }: AeSdkMethodsOptions & {
|
|
27
29
|
nodes?: Array<{ name: string; instance: Node }>;
|
|
28
30
|
} = {},
|
|
29
31
|
) {
|
|
@@ -127,6 +129,19 @@ export default class AeSdkBase extends AeSdkMethods {
|
|
|
127
129
|
return [];
|
|
128
130
|
}
|
|
129
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Resolves an account
|
|
134
|
+
* @param account - ak-address, instance of AccountBase, or keypair
|
|
135
|
+
*/
|
|
136
|
+
_resolveAccount(account: OnAccount = this._options.onAccount): AccountBase {
|
|
137
|
+
if (typeof account === 'string') throw new NotImplementedError('Address in AccountResolver');
|
|
138
|
+
if (typeof account === 'object') return account;
|
|
139
|
+
throw new TypeError(
|
|
140
|
+
'Account should be an address (ak-prefixed string), '
|
|
141
|
+
+ `or instance of AccountBase, got ${String(account)} instead`,
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
130
145
|
get address(): Encoded.AccountAddress {
|
|
131
146
|
return this._resolveAccount().address;
|
|
132
147
|
}
|
|
@@ -153,15 +168,25 @@ export default class AeSdkBase extends AeSdkMethods {
|
|
|
153
168
|
return this._resolveAccount(onAccount).signMessage(message, options);
|
|
154
169
|
}
|
|
155
170
|
|
|
156
|
-
|
|
171
|
+
async signTypedData(
|
|
172
|
+
data: Encoded.ContractBytearray,
|
|
173
|
+
aci: Parameters<AccountBase['signTypedData']>[1],
|
|
174
|
+
{ onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signTypedData']>[2] = {},
|
|
175
|
+
): Promise<Encoded.Signature> {
|
|
176
|
+
return this._resolveAccount(onAccount).signTypedData(data, aci, options);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
override _getOptions(callOptions: AeSdkMethodsOptions = {}): {
|
|
157
180
|
onNode: Node;
|
|
158
181
|
onAccount: AccountBase;
|
|
159
182
|
onCompiler: CompilerBase;
|
|
160
183
|
} {
|
|
161
184
|
return {
|
|
162
|
-
...
|
|
185
|
+
...this._options,
|
|
163
186
|
onNode: getValueOrErrorProxy(() => this.api),
|
|
164
187
|
onCompiler: getValueOrErrorProxy(() => this.compilerApi),
|
|
188
|
+
...callOptions,
|
|
189
|
+
onAccount: getValueOrErrorProxy(() => this._resolveAccount(callOptions.onAccount)),
|
|
165
190
|
};
|
|
166
191
|
}
|
|
167
192
|
}
|