UNPKG

@simbachain/libsimba-js

Version:

libsimba-js is a library simplifying the use of SIMBAChain APIs. We aim to abstract away the various blockchain concepts, reducing the necessary time needed to get to working code.

1,476 lines 593 kB
{ "type": "File", "start": 0, "end": 5393, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 154, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 5393, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 154, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 30, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 30 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 13, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 13 } }, "local": { "type": "Identifier", "start": 7, "end": 13, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 13 }, "identifierName": "Wallet" }, "name": "Wallet" } } ], "source": { "type": "StringLiteral", "start": 19, "end": 29, "loc": { "start": { "line": 1, "column": 19 }, "end": { "line": 1, "column": 29 } }, "extra": { "rawValue": "./wallet", "raw": "'./wallet'" }, "value": "./wallet" } }, { "type": "ImportDeclaration", "start": 31, "end": 94, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 63 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 40, "end": 62, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 31 } }, "imported": { "type": "Identifier", "start": 40, "end": 46, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 15 }, "identifierName": "Wallet" }, "name": "Wallet" }, "local": { "type": "Identifier", "start": 50, "end": 62, "loc": { "start": { "line": 2, "column": 19 }, "end": { "line": 2, "column": 31 }, "identifierName": "EthersWallet" }, "name": "EthersWallet" } } ], "source": { "type": "StringLiteral", "start": 70, "end": 93, "loc": { "start": { "line": 2, "column": 39 }, "end": { "line": 2, "column": 62 } }, "extra": { "rawValue": "@ethersproject/wallet", "raw": "'@ethersproject/wallet'" }, "value": "@ethersproject/wallet" } }, { "type": "ImportDeclaration", "start": 95, "end": 221, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 126 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 104, "end": 120, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 25 } }, "imported": { "type": "Identifier", "start": 104, "end": 120, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 25 }, "identifierName": "SigningException" }, "name": "SigningException" }, "local": { "type": "Identifier", "start": 104, "end": 120, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 25 }, "identifierName": "SigningException" }, "name": "SigningException" } }, { "type": "ImportSpecifier", "start": 122, "end": 150, "loc": { "start": { "line": 3, "column": 27 }, "end": { "line": 3, "column": 55 } }, "imported": { "type": "Identifier", "start": 122, "end": 150, "loc": { "start": { "line": 3, "column": 27 }, "end": { "line": 3, "column": 55 }, "identifierName": "UserRejectedSigningException" }, "name": "UserRejectedSigningException" }, "local": { "type": "Identifier", "start": 122, "end": 150, "loc": { "start": { "line": 3, "column": 27 }, "end": { "line": 3, "column": 55 }, "identifierName": "UserRejectedSigningException" }, "name": "UserRejectedSigningException" } }, { "type": "ImportSpecifier", "start": 152, "end": 175, "loc": { "start": { "line": 3, "column": 57 }, "end": { "line": 3, "column": 80 } }, "imported": { "type": "Identifier", "start": 152, "end": 175, "loc": { "start": { "line": 3, "column": 57 }, "end": { "line": 3, "column": 80 }, "identifierName": "WalletNotFoundException" }, "name": "WalletNotFoundException" }, "local": { "type": "Identifier", "start": 152, "end": 175, "loc": { "start": { "line": 3, "column": 57 }, "end": { "line": 3, "column": 80 }, "identifierName": "WalletNotFoundException" }, "name": "WalletNotFoundException" } }, { "type": "ImportSpecifier", "start": 177, "end": 198, "loc": { "start": { "line": 3, "column": 82 }, "end": { "line": 3, "column": 103 } }, "imported": { "type": "Identifier", "start": 177, "end": 198, "loc": { "start": { "line": 3, "column": 82 }, "end": { "line": 3, "column": 103 }, "identifierName": "WalletLockedException" }, "name": "WalletLockedException" }, "local": { "type": "Identifier", "start": 177, "end": 198, "loc": { "start": { "line": 3, "column": 82 }, "end": { "line": 3, "column": 103 }, "identifierName": "WalletLockedException" }, "name": "WalletLockedException" } } ], "source": { "type": "StringLiteral", "start": 205, "end": 220, "loc": { "start": { "line": 3, "column": 110 }, "end": { "line": 3, "column": 125 } }, "extra": { "rawValue": "../exceptions", "raw": "\"../exceptions\"" }, "value": "../exceptions" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * libsimba-js Private Key Wallet implementation\n * Use when you already have access to the decrypted private key\n * Wraps the [ethersjs]{@link https://docs.ethers.io/ethers.js/html/} library.\n ", "start": 223, "end": 423, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 9, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 424, "end": 5392, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 153, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 439, "end": 5392, "loc": { "start": { "line": 10, "column": 15 }, "end": { "line": 153, "column": 1 } }, "id": { "type": "Identifier", "start": 445, "end": 453, "loc": { "start": { "line": 10, "column": 21 }, "end": { "line": 10, "column": 29 }, "identifierName": "PKWallet" }, "name": "PKWallet", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 462, "end": 468, "loc": { "start": { "line": 10, "column": 38 }, "end": { "line": 10, "column": 44 }, "identifierName": "Wallet" }, "name": "Wallet" }, "body": { "type": "ClassBody", "start": 469, "end": 5392, "loc": { "start": { "line": 10, "column": 45 }, "end": { "line": 153, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 852, "end": 1021, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 21, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 852, "end": 863, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 864, "end": 875, "loc": { "start": { "line": 17, "column": 16 }, "end": { "line": 17, "column": 27 }, "identifierName": "private_key" }, "name": "private_key" }, { "type": "Identifier", "start": 877, "end": 896, "loc": { "start": { "line": 17, "column": 29 }, "end": { "line": 17, "column": 48 }, "identifierName": "signingConfirmation" }, "name": "signingConfirmation" } ], "body": { "type": "BlockStatement", "start": 898, "end": 1021, "loc": { "start": { "line": 17, "column": 50 }, "end": { "line": 21, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 908, "end": 935, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 35 } }, "expression": { "type": "CallExpression", "start": 908, "end": 934, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 34 } }, "callee": { "type": "Super", "start": 908, "end": 913, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 13 } } }, "arguments": [ { "type": "Identifier", "start": 914, "end": 933, "loc": { "start": { "line": 18, "column": 14 }, "end": { "line": 18, "column": 33 }, "identifierName": "signingConfirmation" }, "name": "signingConfirmation" } ] } }, { "type": "ExpressionStatement", "start": 944, "end": 966, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 30 } }, "expression": { "type": "AssignmentExpression", "start": 944, "end": 965, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 29 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 944, "end": 951, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 15 } }, "object": { "type": "ThisExpression", "start": 944, "end": 948, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 12 } } }, "property": { "type": "Identifier", "start": 949, "end": 951, "loc": { "start": { "line": 19, "column": 13 }, "end": { "line": 19, "column": 15 }, "identifierName": "pk" }, "name": "pk" }, "computed": false }, "right": { "type": "Identifier", "start": 954, "end": 965, "loc": { "start": { "line": 19, "column": 18 }, "end": { "line": 19, "column": 29 }, "identifierName": "private_key" }, "name": "private_key" } } }, { "type": "ExpressionStatement", "start": 975, "end": 1015, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 48 } }, "expression": { "type": "AssignmentExpression", "start": 975, "end": 1014, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 47 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 975, "end": 986, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 19 } }, "object": { "type": "ThisExpression", "start": 975, "end": 979, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 12 } } }, "property": { "type": "Identifier", "start": 980, "end": 986, "loc": { "start": { "line": 20, "column": 13 }, "end": { "line": 20, "column": 19 }, "identifierName": "wallet" }, "name": "wallet" }, "computed": false }, "right": { "type": "NewExpression", "start": 989, "end": 1014, "loc": { "start": { "line": 20, "column": 22 }, "end": { "line": 20, "column": 47 } }, "callee": { "type": "Identifier", "start": 993, "end": 1005, "loc": { "start": { "line": 20, "column": 26 }, "end": { "line": 20, "column": 38 }, "identifierName": "EthersWallet" }, "name": "EthersWallet" }, "arguments": [ { "type": "MemberExpression", "start": 1006, "end": 1013, "loc": { "start": { "line": 20, "column": 39 }, "end": { "line": 20, "column": 46 } }, "object": { "type": "ThisExpression", "start": 1006, "end": 1010, "loc": { "start": { "line": 20, "column": 39 }, "end": { "line": 20, "column": 43 } } }, "property": { "type": "Identifier", "start": 1011, "end": 1013, "loc": { "start": { "line": 20, "column": 44 }, "end": { "line": 20, "column": 46 }, "identifierName": "pk" }, "name": "pk" }, "computed": false } ] } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Use when you already have access to the decrypted private key\n * @param {string} [private_key] - The private key in hexidecimal format\n * @param {function} [signingConfirmation] - - an optional callback for requesting user permission to sign a\n * transaction. Should resolve a promise with true for accept, and false (or reject) for reject.\n ", "start": 475, "end": 847, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 16, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @override\n * Unlock the wallet - noop for this wallet\n * @param {string} passkey - The pass key to unlock the wallet\n * @param {function} [progressCB] - A callback, accepting a number between 0-1, indicating decryption progress\n * @returns {Promise} - Returns a promise resolving when the wallet is unlocked\n ", "start": 1027, "end": 1369, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 29, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1374, "end": 1448, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 32, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1374, "end": 1386, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 30, "column": 16 }, "identifierName": "unlockWallet" }, "name": "unlockWallet", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1387, "end": 1394, "loc": { "start": { "line": 30, "column": 17 }, "end": { "line": 30, "column": 24 }, "identifierName": "passkey" }, "name": "passkey" }, { "type": "Identifier", "start": 1396, "end": 1406, "loc": { "start": { "line": 30, "column": 26 }, "end": { "line": 30, "column": 36 }, "identifierName": "progressCB" }, "name": "progressCB" } ], "body": { "type": "BlockStatement", "start": 1407, "end": 1448, "loc": { "start": { "line": 30, "column": 37 }, "end": { "line": 32, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 1417, "end": 1442, "loc": { "start": { "line": 31, "column": 8 }, "end": { "line": 31, "column": 33 } }, "argument": { "type": "CallExpression", "start": 1424, "end": 1441, "loc": { "start": { "line": 31, "column": 15 }, "end": { "line": 31, "column": 32 } }, "callee": { "type": "MemberExpression", "start": 1424, "end": 1439, "loc": { "start": { "line": 31, "column": 15 }, "end": { "line": 31, "column": 30 } }, "object": { "type": "Identifier", "start": 1424, "end": 1431, "loc": { "start": { "line": 31, "column": 15 }, "end": { "line": 31, "column": 22 }, "identifierName": "Promise" }, "name": "Promise" }, "property": { "type": "Identifier", "start": 1432, "end": 1439, "loc": { "start": { "line": 31, "column": 23 }, "end": { "line": 31, "column": 30 }, "identifierName": "resolve" }, "name": "resolve" }, "computed": false }, "arguments": [] } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @override\n * Unlock the wallet - noop for this wallet\n * @param {string} passkey - The pass key to unlock the wallet\n * @param {function} [progressCB] - A callback, accepting a number between 0-1, indicating decryption progress\n * @returns {Promise} - Returns a promise resolving when the wallet is unlocked\n ", "start": 1027, "end": 1369, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 29, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @override\n * Generate a wallet\n * @param {string} passkey - The pass key to lock the wallet\n * @param {function} [progressCB] - A callback, accepting a number between 0-1, indicating decryption progress\n * @returns {Promise} - Returns a promise resolving with the private key when the wallet is created\n ", "start": 1454, "end": 1791, "loc": { "start": { "line": 34, "column": 4 }, "end": { "line": 40, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1796, "end": 1963, "loc": { "start": { "line": 41, "column": 4 }, "end": { "line": 45, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1796, "end": 1810, "loc": { "start": { "line": 41, "column": 4 }, "end": { "line": 41, "column": 18 }, "identifierName": "generateWallet" }, "name": "generateWallet", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1811, "end": 1821, "loc": { "start": { "line": 41, "column": 19 }, "end": { "line": 41, "column": 29 }, "identifierName": "progressCB" }, "name": "progressCB" } ], "body": { "type": "BlockStatement", "start": 1822, "end": 1963, "loc": { "start": { "line": 41, "column": 30 }, "end": { "line": 45, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1832, "end": 1874, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 50 } }, "expression": { "type": "AssignmentExpression", "start": 1832, "end": 1873, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 49 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1832, "end": 1843, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 19 } }, "object": { "type": "ThisExpression", "start": 1832, "end": 1836, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 12 } } }, "property": { "type": "Identifier", "start": 1837, "end": 1843, "loc": { "start": { "line": 42, "column": 13 }, "end": { "line": 42, "column": 19 }, "identifierName": "wallet" }, "name": "wallet" }, "computed": false }, "right": { "type": "CallExpression", "start": 1846, "end": 1873, "loc": { "start": { "line": 42, "column": 22 }, "end": { "line": 42, "column": 49 } }, "callee": { "type": "MemberExpression", "start": 1846, "end": 1871, "loc": { "start": { "line": 42, "column": 22 }, "end": { "line": 42, "column": 47 } }, "object": { "type": "Identifier", "start": 1846, "end": 1858, "loc": { "start": { "line": 42, "column": 22 }, "end": { "line": 42, "column": 34 }, "identifierName": "EthersWallet" }, "name": "EthersWallet" }, "property": { "type": "Identifier", "start": 1859, "end": 1871, "loc": { "start": { "line": 42, "column": 35 }, "end": { "line": 42, "column": 47 }, "identifierName": "createRandom" }, "name": "createRandom" }, "computed": false }, "arguments": [] } } }, { "type": "ExpressionStatement", "start": 1883, "end": 1916, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 41 } }, "expression": { "type": "AssignmentExpression", "start": 1883, "end": 1915, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 40 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1883, "end": 1890, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 15 } }, "object": { "type": "ThisExpression", "start": 1883, "end": 1887, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 12 } } }, "property": { "type": "Identifier", "start": 1888, "end": 1890, "loc": { "start": { "line": 43, "column": 13 }, "end": { "line": 43, "column": 15 }, "identifierName": "pk" }, "name": "pk" }, "computed": false }, "right": { "type": "MemberExpression", "start":