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,511 lines 573 kB
{ "type": "File", "start": 0, "end": 5546, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 154, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 5546, "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": 32, "end": 95, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 63 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 41, "end": 63, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 31 } }, "imported": { "type": "Identifier", "start": 41, "end": 47, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 15 }, "identifierName": "Wallet" }, "name": "Wallet" }, "local": { "type": "Identifier", "start": 51, "end": 63, "loc": { "start": { "line": 2, "column": 19 }, "end": { "line": 2, "column": 31 }, "identifierName": "EthersWallet" }, "name": "EthersWallet" } } ], "source": { "type": "StringLiteral", "start": 71, "end": 94, "loc": { "start": { "line": 2, "column": 39 }, "end": { "line": 2, "column": 62 } }, "extra": { "rawValue": "@ethersproject/wallet", "raw": "'@ethersproject/wallet'" }, "value": "@ethersproject/wallet" } }, { "type": "ImportDeclaration", "start": 97, "end": 223, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 126 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 106, "end": 122, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 25 } }, "imported": { "type": "Identifier", "start": 106, "end": 122, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 25 }, "identifierName": "SigningException" }, "name": "SigningException" }, "local": { "type": "Identifier", "start": 106, "end": 122, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 25 }, "identifierName": "SigningException" }, "name": "SigningException" } }, { "type": "ImportSpecifier", "start": 124, "end": 152, "loc": { "start": { "line": 3, "column": 27 }, "end": { "line": 3, "column": 55 } }, "imported": { "type": "Identifier", "start": 124, "end": 152, "loc": { "start": { "line": 3, "column": 27 }, "end": { "line": 3, "column": 55 }, "identifierName": "UserRejectedSigningException" }, "name": "UserRejectedSigningException" }, "local": { "type": "Identifier", "start": 124, "end": 152, "loc": { "start": { "line": 3, "column": 27 }, "end": { "line": 3, "column": 55 }, "identifierName": "UserRejectedSigningException" }, "name": "UserRejectedSigningException" } }, { "type": "ImportSpecifier", "start": 154, "end": 177, "loc": { "start": { "line": 3, "column": 57 }, "end": { "line": 3, "column": 80 } }, "imported": { "type": "Identifier", "start": 154, "end": 177, "loc": { "start": { "line": 3, "column": 57 }, "end": { "line": 3, "column": 80 }, "identifierName": "WalletNotFoundException" }, "name": "WalletNotFoundException" }, "local": { "type": "Identifier", "start": 154, "end": 177, "loc": { "start": { "line": 3, "column": 57 }, "end": { "line": 3, "column": 80 }, "identifierName": "WalletNotFoundException" }, "name": "WalletNotFoundException" } }, { "type": "ImportSpecifier", "start": 179, "end": 200, "loc": { "start": { "line": 3, "column": 82 }, "end": { "line": 3, "column": 103 } }, "imported": { "type": "Identifier", "start": 179, "end": 200, "loc": { "start": { "line": 3, "column": 82 }, "end": { "line": 3, "column": 103 }, "identifierName": "WalletLockedException" }, "name": "WalletLockedException" }, "local": { "type": "Identifier", "start": 179, "end": 200, "loc": { "start": { "line": 3, "column": 82 }, "end": { "line": 3, "column": 103 }, "identifierName": "WalletLockedException" }, "name": "WalletLockedException" } } ], "source": { "type": "StringLiteral", "start": 207, "end": 222, "loc": { "start": { "line": 3, "column": 110 }, "end": { "line": 3, "column": 125 } }, "extra": { "rawValue": "../exceptions", "raw": "\"../exceptions\"" }, "value": "../exceptions" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\r\n * libsimba-js Private Key Wallet implementation\r\n * Use when you already have access to the decrypted private key\r\n * Wraps the [ethersjs]{@link https://docs.ethers.io/ethers.js/html/} library.\r\n ", "start": 227, "end": 431, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 9, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 433, "end": 5544, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 153, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 448, "end": 5544, "loc": { "start": { "line": 10, "column": 15 }, "end": { "line": 153, "column": 1 } }, "id": { "type": "Identifier", "start": 454, "end": 462, "loc": { "start": { "line": 10, "column": 21 }, "end": { "line": 10, "column": 29 }, "identifierName": "PKWallet" }, "name": "PKWallet", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 471, "end": 477, "loc": { "start": { "line": 10, "column": 38 }, "end": { "line": 10, "column": 44 }, "identifierName": "Wallet" }, "name": "Wallet" }, "body": { "type": "ClassBody", "start": 478, "end": 5544, "loc": { "start": { "line": 10, "column": 45 }, "end": { "line": 153, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 868, "end": 1041, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 21, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 868, "end": 879, "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": 880, "end": 891, "loc": { "start": { "line": 17, "column": 16 }, "end": { "line": 17, "column": 27 }, "identifierName": "private_key" }, "name": "private_key" }, { "type": "Identifier", "start": 893, "end": 912, "loc": { "start": { "line": 17, "column": 29 }, "end": { "line": 17, "column": 48 }, "identifierName": "signingConfirmation" }, "name": "signingConfirmation" } ], "body": { "type": "BlockStatement", "start": 914, "end": 1041, "loc": { "start": { "line": 17, "column": 50 }, "end": { "line": 21, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 925, "end": 952, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 35 } }, "expression": { "type": "CallExpression", "start": 925, "end": 951, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 34 } }, "callee": { "type": "Super", "start": 925, "end": 930, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 13 } } }, "arguments": [ { "type": "Identifier", "start": 931, "end": 950, "loc": { "start": { "line": 18, "column": 14 }, "end": { "line": 18, "column": 33 }, "identifierName": "signingConfirmation" }, "name": "signingConfirmation" } ] } }, { "type": "ExpressionStatement", "start": 962, "end": 984, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 30 } }, "expression": { "type": "AssignmentExpression", "start": 962, "end": 983, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 29 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 962, "end": 969, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 15 } }, "object": { "type": "ThisExpression", "start": 962, "end": 966, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 12 } } }, "property": { "type": "Identifier", "start": 967, "end": 969, "loc": { "start": { "line": 19, "column": 13 }, "end": { "line": 19, "column": 15 }, "identifierName": "pk" }, "name": "pk" }, "computed": false }, "right": { "type": "Identifier", "start": 972, "end": 983, "loc": { "start": { "line": 19, "column": 18 }, "end": { "line": 19, "column": 29 }, "identifierName": "private_key" }, "name": "private_key" } } }, { "type": "ExpressionStatement", "start": 994, "end": 1034, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 48 } }, "expression": { "type": "AssignmentExpression", "start": 994, "end": 1033, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 47 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 994, "end": 1005, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 19 } }, "object": { "type": "ThisExpression", "start": 994, "end": 998, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 12 } } }, "property": { "type": "Identifier", "start": 999, "end": 1005, "loc": { "start": { "line": 20, "column": 13 }, "end": { "line": 20, "column": 19 }, "identifierName": "wallet" }, "name": "wallet" }, "computed": false }, "right": { "type": "NewExpression", "start": 1008, "end": 1033, "loc": { "start": { "line": 20, "column": 22 }, "end": { "line": 20, "column": 47 } }, "callee": { "type": "Identifier", "start": 1012, "end": 1024, "loc": { "start": { "line": 20, "column": 26 }, "end": { "line": 20, "column": 38 }, "identifierName": "EthersWallet" }, "name": "EthersWallet" }, "arguments": [ { "type": "MemberExpression", "start": 1025, "end": 1032, "loc": { "start": { "line": 20, "column": 39 }, "end": { "line": 20, "column": 46 } }, "object": { "type": "ThisExpression", "start": 1025, "end": 1029, "loc": { "start": { "line": 20, "column": 39 }, "end": { "line": 20, "column": 43 } } }, "property": { "type": "Identifier", "start": 1030, "end": 1032, "loc": { "start": { "line": 20, "column": 44 }, "end": { "line": 20, "column": 46 }, "identifierName": "pk" }, "name": "pk" }, "computed": false } ] } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\r\n * Use when you already have access to the decrypted private key\r\n * @param {string} [private_key] - The private key in hexidecimal format\r\n * @param {function} [signingConfirmation] - - an optional callback for requesting user permission to sign a\r\n * transaction. Should resolve a promise with true for accept, and false (or reject) for reject.\r\n ", "start": 485, "end": 862, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 16, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\r\n * @override\r\n * Unlock the wallet - noop for this wallet\r\n * @param {string} passkey - The pass key to unlock the wallet\r\n * @param {function} [progressCB] - A callback, accepting a number between 0-1, indicating decryption progress\r\n * @returns {Promise} - Returns a promise resolving when the wallet is unlocked\r\n ", "start": 1049, "end": 1397, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 29, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1403, "end": 1479, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 32, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1403, "end": 1415, "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": 1416, "end": 1423, "loc": { "start": { "line": 30, "column": 17 }, "end": { "line": 30, "column": 24 }, "identifierName": "passkey" }, "name": "passkey" }, { "type": "Identifier", "start": 1425, "end": 1435, "loc": { "start": { "line": 30, "column": 26 }, "end": { "line": 30, "column": 36 }, "identifierName": "progressCB" }, "name": "progressCB" } ], "body": { "type": "BlockStatement", "start": 1436, "end": 1479, "loc": { "start": { "line": 30, "column": 37 }, "end": { "line": 32, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 1447, "end": 1472, "loc": { "start": { "line": 31, "column": 8 }, "end": { "line": 31, "column": 33 } }, "argument": { "type": "CallExpression", "start": 1454, "end": 1471, "loc": { "start": { "line": 31, "column": 15 }, "end": { "line": 31, "column": 32 } }, "callee": { "type": "MemberExpression", "start": 1454, "end": 1469, "loc": { "start": { "line": 31, "column": 15 }, "end": { "line": 31, "column": 30 } }, "object": { "type": "Identifier", "start": 1454, "end": 1461, "loc": { "start": { "line": 31, "column": 15 }, "end": { "line": 31, "column": 22 }, "identifierName": "Promise" }, "name": "Promise" }, "property": { "type": "Identifier", "start": 1462, "end": 1469, "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": "*\r\n * @override\r\n * Unlock the wallet - noop for this wallet\r\n * @param {string} passkey - The pass key to unlock the wallet\r\n * @param {function} [progressCB] - A callback, accepting a number between 0-1, indicating decryption progress\r\n * @returns {Promise} - Returns a promise resolving when the wallet is unlocked\r\n ", "start": 1049, "end": 1397, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 29, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\r\n * @override\r\n * Generate a wallet\r\n * @param {string} passkey - The pass key to lock the wallet\r\n * @param {function} [progressCB] - A callback, accepting a number between 0-1, indicating decryption progress\r\n * @returns {Promise} - Returns a promise resolving with the private key when the wallet is created\r\n ", "start": 1487, "end": 1830, "loc": { "start": { "line": 34, "column": 4 }, "end": { "line": 40, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1836, "end": 2007, "loc": { "start": { "line": 41, "column": 4 }, "end": { "line": 45, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1836, "end": 1850, "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": 1851, "end": 1861, "loc": { "start": { "line": 41, "column": 19 }, "end": { "line": 41, "column": 29 }, "identifierName": "progressCB" }, "name": "progressCB" } ], "body": { "type": "BlockStatement", "start": 1862, "end": 2007, "loc": { "start": { "line": 41, "column": 30 }, "end": { "line": 45, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1873, "end": 1915, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 50 } }, "expression": { "type": "AssignmentExpression", "start": 1873, "end": 1914, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 49 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1873, "end": 1884, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 19 } }, "object": { "type": "ThisExpression", "start": 1873, "end": 1877, "loc": { "start": { "line": 42, "column": 8 }, "end": { "line": 42, "column": 12 } } }, "property": { "type": "Identifier", "start": 1878, "end": 1884, "loc": { "start": { "line": 42, "column": 13 }, "end": { "line": 42, "column": 19 }, "identifierName": "wallet" }, "name": "wallet" }, "computed": false }, "right": { "type": "CallExpression", "start": 1887, "end": 1914, "loc": { "start": { "line": 42, "column": 22 }, "end": { "line": 42, "column": 49 } }, "callee": { "type": "MemberExpression", "start": 1887, "end": 1912, "loc": { "start": { "line": 42, "column": 22 }, "end": { "line": 42, "column": 47 } }, "object": { "type": "Identifier", "start": 1887, "end": 1899, "loc": { "start": { "line": 42, "column": 22 }, "end": { "line": 42, "column": 34 }, "identifierName": "EthersWallet" }, "name": "EthersWallet" }, "property": { "type": "Identifier", "start": 1900, "end": 1912, "loc": { "start": { "line": 42, "column": 35 }, "end": { "line": 42, "column": 47 }, "identifierName": "createRandom" }, "name": "createRandom" }, "computed": false }, "arguments": [] } } }, { "type": "ExpressionStatement", "start": 1925, "end": 1958, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 41 } }, "expression": { "type": "AssignmentExpression", "start": 1925, "end": 1957, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 40 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1925, "end": 1932, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 15 } }, "object": { "type": "ThisExpression", "start": 1925, "end": 1929, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 12 } } }, "property": { "type": "Identifier", "start": 1930, "end": 1932, "loc": { "start": { "line": 43, "column": 13 }, "end": { "line": 43, "column": 15 }, "identifierName": "pk" }, "name": "pk" }, "computed": false }, "right": { "type": "MemberExpression", "start": 1935, "end": 1957, "loc": { "start": { "line": 43, "column": 18 }, "end": { "line": 43, "column": 40 } }, "object": { "type": "MemberExpression", "start": 1935, "end": 1946, "loc": { "start": { "line": 43, "column": 18 }, "end": { "line": 43, "column": 29 } }, "object": { "type": "ThisExpression", "start": 1935, "end": 1939, "loc": { "start": { "line": 43, "column": 18 }, "end":