@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,463 lines (1,462 loc) • 836 kB
JSON
{
"type": "File",
"start": 0,
"end": 8041,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 207,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 8041,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 207,
"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": 246,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 149
}
},
"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"
}
},
{
"type": "ImportSpecifier",
"start": 202,
"end": 223,
"loc": {
"start": {
"line": 3,
"column": 105
},
"end": {
"line": 3,
"column": 126
}
},
"imported": {
"type": "Identifier",
"start": 202,
"end": 223,
"loc": {
"start": {
"line": 3,
"column": 105
},
"end": {
"line": 3,
"column": 126
},
"identifierName": "NotInBrowserException"
},
"name": "NotInBrowserException"
},
"local": {
"type": "Identifier",
"start": 202,
"end": 223,
"loc": {
"start": {
"line": 3,
"column": 105
},
"end": {
"line": 3,
"column": 126
},
"identifierName": "NotInBrowserException"
},
"name": "NotInBrowserException"
}
}
],
"source": {
"type": "StringLiteral",
"start": 230,
"end": 245,
"loc": {
"start": {
"line": 3,
"column": 133
},
"end": {
"line": 3,
"column": 148
}
},
"extra": {
"rawValue": "../exceptions",
"raw": "\"../exceptions\""
},
"value": "../exceptions"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\r\n * libsimba-js Local Wallet implementation\r\n * Stores the wallet as encrypted json within the browsers localstorage\r\n * Wraps the [ethersjs]{@link https://docs.ethers.io/ethers.js/html/} library.\r\n ",
"start": 250,
"end": 455,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 9,
"column": 3
}
}
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 457,
"end": 8039,
"loc": {
"start": {
"line": 10,
"column": 0
},
"end": {
"line": 206,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 472,
"end": 8039,
"loc": {
"start": {
"line": 10,
"column": 15
},
"end": {
"line": 206,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 478,
"end": 489,
"loc": {
"start": {
"line": 10,
"column": 21
},
"end": {
"line": 10,
"column": 32
},
"identifierName": "LocalWallet"
},
"name": "LocalWallet",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 498,
"end": 504,
"loc": {
"start": {
"line": 10,
"column": 41
},
"end": {
"line": 10,
"column": 47
},
"identifierName": "Wallet"
},
"name": "Wallet"
},
"body": {
"type": "ClassBody",
"start": 505,
"end": 8039,
"loc": {
"start": {
"line": 10,
"column": 48
},
"end": {
"line": 206,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 805,
"end": 1064,
"loc": {
"start": {
"line": 16,
"column": 4
},
"end": {
"line": 23,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 805,
"end": 816,
"loc": {
"start": {
"line": 16,
"column": 4
},
"end": {
"line": 16,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor",
"leadingComments": null
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 817,
"end": 836,
"loc": {
"start": {
"line": 16,
"column": 16
},
"end": {
"line": 16,
"column": 35
},
"identifierName": "signingConfirmation"
},
"name": "signingConfirmation"
}
],
"body": {
"type": "BlockStatement",
"start": 838,
"end": 1064,
"loc": {
"start": {
"line": 16,
"column": 37
},
"end": {
"line": 23,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 849,
"end": 876,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 35
}
},
"expression": {
"type": "CallExpression",
"start": 849,
"end": 875,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 34
}
},
"callee": {
"type": "Super",
"start": 849,
"end": 854,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 13
}
}
},
"arguments": [
{
"type": "Identifier",
"start": 855,
"end": 874,
"loc": {
"start": {
"line": 17,
"column": 14
},
"end": {
"line": 17,
"column": 33
},
"identifierName": "signingConfirmation"
},
"name": "signingConfirmation"
}
]
}
},
{
"type": "IfStatement",
"start": 886,
"end": 1024,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 20,
"column": 9
}
},
"test": {
"type": "BinaryExpression",
"start": 889,
"end": 918,
"loc": {
"start": {
"line": 18,
"column": 11
},
"end": {
"line": 18,
"column": 40
}
},
"left": {
"type": "UnaryExpression",
"start": 889,
"end": 902,
"loc": {
"start": {
"line": 18,
"column": 11
},
"end": {
"line": 18,
"column": 24
}
},
"operator": "typeof",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 896,
"end": 902,
"loc": {
"start": {
"line": 18,
"column": 18
},
"end": {
"line": 18,
"column": 24
},
"identifierName": "window"
},
"name": "window"
},
"extra": {
"parenthesizedArgument": false
}
},
"operator": "===",
"right": {
"type": "StringLiteral",
"start": 907,
"end": 918,
"loc": {
"start": {
"line": 18,
"column": 29
},
"end": {
"line": 18,
"column": 40
}
},
"extra": {
"rawValue": "undefined",
"raw": "'undefined'"
},
"value": "undefined"
}
},
"consequent": {
"type": "BlockStatement",
"start": 920,
"end": 1024,
"loc": {
"start": {
"line": 18,
"column": 42
},
"end": {
"line": 20,
"column": 9
}
},
"body": [
{
"type": "ThrowStatement",
"start": 935,
"end": 1013,
"loc": {
"start": {
"line": 19,
"column": 12
},
"end": {
"line": 19,
"column": 90
}
},
"argument": {
"type": "NewExpression",
"start": 941,
"end": 1012,
"loc": {
"start": {
"line": 19,
"column": 18
},
"end": {
"line": 19,
"column": 89
}
},
"callee": {
"type": "Identifier",
"start": 945,
"end": 966,
"loc": {
"start": {
"line": 19,
"column": 22
},
"end": {
"line": 19,
"column": 43
},
"identifierName": "NotInBrowserException"
},
"name": "NotInBrowserException"
},
"arguments": [
{
"type": "StringLiteral",
"start": 967,
"end": 1011,
"loc": {
"start": {
"line": 19,
"column": 44
},
"end": {
"line": 19,
"column": 88
}
},
"extra": {
"rawValue": "LocalWallet can only be used in a browser!",
"raw": "\"LocalWallet can only be used in a browser!\""
},
"value": "LocalWallet can only be used in a browser!"
}
]
}
}
],
"directives": []
},
"alternate": null
},
{
"type": "ExpressionStatement",
"start": 1036,
"end": 1057,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 29
}
},
"expression": {
"type": "AssignmentExpression",
"start": 1036,
"end": 1056,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 28
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 1036,
"end": 1047,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 19
}
},
"object": {
"type": "ThisExpression",
"start": 1036,
"end": 1040,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1041,
"end": 1047,
"loc": {
"start": {
"line": 22,
"column": 13
},
"end": {
"line": 22,
"column": 19
},
"identifierName": "window"
},
"name": "window"
},
"computed": false
},
"right": {
"type": "Identifier",
"start": 1050,
"end": 1056,
"loc": {
"start": {
"line": 22,
"column": 22
},
"end": {
"line": 22,
"column": 28
},
"identifierName": "window"
},
"name": "window"
}
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\r\n * Use a wallet stored in the browsers local storage\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": 512,
"end": 799,
"loc": {
"start": {
"line": 11,
"column": 4
},
"end": {
"line": 15,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\r\n * @override\r\n * Unlock the 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": 1072,
"end": 1397,
"loc": {
"start": {
"line": 25,
"column": 4
},
"end": {
"line": 31,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 1403,
"end": 1611,
"loc": {
"start": {
"line": 32,
"column": 4
},
"end": {
"line": 35,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 1403,
"end": 1415,
"loc": {
"start": {
"line": 32,
"column": 4
},
"end": {
"line": 32,
"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": 32,
"column": 17
},
"end": {
"line": 32,
"column": 24
},
"identifierName": "passkey"
},
"name": "passkey"
},
{
"type": "Identifier",
"start": 1425,
"end": 1435,
"loc": {
"start": {
"line": 32,
"column": 26
},
"end": {
"line": 32,
"column": 36
},
"identifierName": "progressCB"
},
"name": "progressCB"
}
],
"body": {
"type": "BlockStatement",
"start": 1436,
"end": 1611,
"loc": {
"start": {
"line": 32,
"column": 37
},
"end": {
"line": 35,
"column": 5
}
},
"body": [
{
"type": "ReturnStatement",
"start": 1447,
"end": 1604,
"loc": {
"start": {
"line": 33,
"column": 8
},
"end": {
"line": 34,
"column": 48
}
},
"argument": {
"type": "CallExpression",
"start": 1454,
"end": 1603,
"loc": {
"start": {
"line": 33,
"column": 15
},
"end": {
"line": 34,
"column": 47
}
},
"callee": {
"type": "MemberExpression",
"start": 1454,
"end": 1573,
"loc": {
"start": {
"line": 33,
"column": 15
},
"end": {
"line": 34,
"column": 17
}
},
"object": {
"type": "CallExpression",
"start": 1454,
"end": 1554,
"loc": {
"start": {
"line": 33,
"column": 15
},
"end": {
"line": 33,
"column": 115
}
},
"callee": {
"type": "MemberExpression",
"start": 1454,
"end": 1484,
"loc": {
"start": {
"line": 33,
"column": 15
},
"end": {
"line": 33,
"column": 45
}
},
"object": {
"type": "Identifier",
"start": 1454,
"end": 1466,
"loc": {
"start": {
"line": 33,
"column": 15
},
"end": {
"line": 33,
"column": 27
},
"identifierName": "EthersWallet"
},
"name": "EthersWallet"
},
"property": {
"type": "Identifier",
"start": 1467,
"end": 1484,
"loc": {
"start": {
"line": 33,
"column": 28
},
"end": {
"line": 33,
"column": 45
},
"identifierName": "fromEncryptedJson"
},
"name": "fromEncryptedJson"
},
"computed": false
},
"arguments": [
{
"type": "CallExpression",
"start": 1485,
"end": 1532,
"loc": {
"start": {
"line": 33,
"column": 46
},
"end": {
"line": 33,
"column": 93
}
},
"callee": {
"type": "MemberExpression",
"start": 1485,
"end": 1517,
"loc": {
"start": {
"line": 33,
"column": 46
},
"end": {
"line": 33,
"column": 78
}
},
"object": {
"type": "MemberExpression",
"start": 1485,
"end": 1509,
"loc": {
"start": {
"line": 33,
"column": 46
},
"end": {
"line": 33,
"column": 70
}
},
"object": {
"type": "MemberExpression",
"start": 1485,
"end": 1496,
"loc": {
"start": {
"line": 33,
"column": 46
},
"end": {
"line": 33,
"column": 57
}
},
"object": {
"type": "ThisExpression",
"start": 1485,
"end": 1489,
"loc": {
"start": {
"line": 33,
"column": 46
},
"end": {
"line": 33,
"column": 50
}
}
},
"property": {
"type": "Identifier",
"start": 1490,
"end": 1496,
"loc": {
"start": {
"line": 33,
"column": 51
},
"end": {
"line": 33,
"column": 57
},
"identifierName": "window"
},
"name": "window"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 1497,
"end": 1509,
"loc": {
"start": {
"line": 33,
"column": 58
},
"end": {
"line": 33,
"column": 70
},
"identifierName": "localStorage"
},
"name": "localStorage"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 1510,
"end": 1517,
"loc": {
"start": {
"line": 33,
"column": 71
},
"end": {
"line": 33,
"column": 78
},
"identifierName": "getItem"
},
"name": "getItem"
},
"computed": false
},
"arguments": [
{
"type": "StringLiteral",
"start": 1518,
"end": 1531,
"loc": {
"start": {
"line": 33,
"column": 79
},
"end": {
"line": 33,
"column": 92
}
},
"extra": {
"rawValue": "localwallet",
"raw": "'localwallet'"
},
"value": "localwallet"
}
]
},
{
"type": "Identifier",
"start": 1534,
"end": 1541,
"loc": {
"start": {
"line": 33,
"column": 95
},
"end": {
"line": 33,
"column": 102
},
"identifierName": "passkey"
},
"name": "passkey"
},
{
"type": "Identifier",
"start": 1543,
"end": 1553,
"loc": {
"start": {
"line": 33,
"column": 104
},
"end": {
"line": 33,
"column": 114
},
"identifierName": "progressCB"
},
"name": "progressCB"
}
]
},
"property": {
"type": "Identifier",
"start": 1569,
"end": 1573,
"loc": {
"start": {
"line": 34,
"column": 13
},
"end": {
"line": 34,
"column": 17
},
"identifierName": "then"
},
"name": "then"
},
"computed": false
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"start": 1574,
"end": 1602,
"loc": {
"start": {
"line": 34,
"column": 18
},
"end": {
"line": 34,
"column": 46
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1574,
"end": 1580,
"loc": {
"start": {
"line": 34,
"column": 18
},
"end": {
"line": 34,
"column": 24
},
"identifierName": "wallet"
},
"name": "wallet"
}
],
"body": {
"type": "AssignmentExpression",
"start": 1582,
"end": 1602,
"loc": {
"start": {
"line": 34,
"column": 26