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,381 lines (1,380 loc) 172 kB
{ "type": "File", "start": 0, "end": 1324, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 44, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 1324, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 44, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 46, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 46 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 8, "end": 17, "loc": { "start": { "line": 1, "column": 8 }, "end": { "line": 1, "column": 17 } }, "imported": { "type": "Identifier", "start": 8, "end": 17, "loc": { "start": { "line": 1, "column": 8 }, "end": { "line": 1, "column": 17 }, "identifierName": "SimbaBase" }, "name": "SimbaBase" }, "local": { "type": "Identifier", "start": 8, "end": 17, "loc": { "start": { "line": 1, "column": 8 }, "end": { "line": 1, "column": 17 }, "identifierName": "SimbaBase" }, "name": "SimbaBase" } }, { "type": "ImportSpecifier", "start": 19, "end": 29, "loc": { "start": { "line": 1, "column": 19 }, "end": { "line": 1, "column": 29 } }, "imported": { "type": "Identifier", "start": 19, "end": 29, "loc": { "start": { "line": 1, "column": 19 }, "end": { "line": 1, "column": 29 }, "identifierName": "Simbachain" }, "name": "Simbachain" }, "local": { "type": "Identifier", "start": 19, "end": 29, "loc": { "start": { "line": 1, "column": 19 }, "end": { "line": 1, "column": 29 }, "identifierName": "Simbachain" }, "name": "Simbachain" } } ], "source": { "type": "StringLiteral", "start": 36, "end": 45, "loc": { "start": { "line": 1, "column": 36 }, "end": { "line": 1, "column": 45 } }, "extra": { "rawValue": "./simba", "raw": "'./simba'" }, "value": "./simba" } }, { "type": "ImportDeclaration", "start": 47, "end": 102, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 55 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 55, "end": 61, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 14 } }, "imported": { "type": "Identifier", "start": 55, "end": 61, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 14 }, "identifierName": "Wallet" }, "name": "Wallet" }, "local": { "type": "Identifier", "start": 55, "end": 61, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 14 }, "identifierName": "Wallet" }, "name": "Wallet" } }, { "type": "ImportSpecifier", "start": 63, "end": 74, "loc": { "start": { "line": 2, "column": 16 }, "end": { "line": 2, "column": 27 } }, "imported": { "type": "Identifier", "start": 63, "end": 74, "loc": { "start": { "line": 2, "column": 16 }, "end": { "line": 2, "column": 27 }, "identifierName": "LocalWallet" }, "name": "LocalWallet" }, "local": { "type": "Identifier", "start": 63, "end": 74, "loc": { "start": { "line": 2, "column": 16 }, "end": { "line": 2, "column": 27 }, "identifierName": "LocalWallet" }, "name": "LocalWallet" } }, { "type": "ImportSpecifier", "start": 76, "end": 84, "loc": { "start": { "line": 2, "column": 29 }, "end": { "line": 2, "column": 37 } }, "imported": { "type": "Identifier", "start": 76, "end": 84, "loc": { "start": { "line": 2, "column": 29 }, "end": { "line": 2, "column": 37 }, "identifierName": "PKWallet" }, "name": "PKWallet" }, "local": { "type": "Identifier", "start": 76, "end": 84, "loc": { "start": { "line": 2, "column": 29 }, "end": { "line": 2, "column": 37 }, "identifierName": "PKWallet" }, "name": "PKWallet" } } ], "source": { "type": "StringLiteral", "start": 91, "end": 101, "loc": { "start": { "line": 2, "column": 44 }, "end": { "line": 2, "column": 54 } }, "extra": { "rawValue": "./wallet", "raw": "'./wallet'" }, "value": "./wallet" } }, { "type": "ImportDeclaration", "start": 103, "end": 156, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 53 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 111, "end": 134, "loc": { "start": { "line": 3, "column": 8 }, "end": { "line": 3, "column": 31 } }, "imported": { "type": "Identifier", "start": 111, "end": 134, "loc": { "start": { "line": 3, "column": 8 }, "end": { "line": 3, "column": 31 }, "identifierName": "NotImplementedException" }, "name": "NotImplementedException" }, "local": { "type": "Identifier", "start": 111, "end": 134, "loc": { "start": { "line": 3, "column": 8 }, "end": { "line": 3, "column": 31 }, "identifierName": "NotImplementedException" }, "name": "NotImplementedException" } } ], "source": { "type": "StringLiteral", "start": 141, "end": 155, "loc": { "start": { "line": 3, "column": 38 }, "end": { "line": 3, "column": 52 } }, "extra": { "rawValue": "./exceptions", "raw": "'./exceptions'" }, "value": "./exceptions" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Create an instance of a Simbachain API interaction class\n * Automatically takes care of choosing the correct implementation and running asynchronous initialisation.\n * @param {string} url - The API URL\n * @param {Wallet} wallet - The Wallet to use\n * @param {string} [apiKey] - (Optional) The API key\n * @param {string} [managementKey] - (Optional) The Management API key\n * @returns {Promise<Simbachain>} - An initialised instance of the API interaction class\n ", "start": 158, "end": 629, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 13, "column": 3 } } } ] }, { "type": "Identifier", "start": 630, "end": 1216, "loc": { "start": { "line": 14, "column": 0 }, "end": { "line": 34, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 636, "end": 1215, "loc": { "start": { "line": 14, "column": 6 }, "end": { "line": 34, "column": 1 } }, "id": { "type": "Identifier", "start": 636, "end": 652, "loc": { "start": { "line": 14, "column": 6 }, "end": { "line": 14, "column": 22 }, "identifierName": "getSimbaInstance" }, "name": "getSimbaInstance", "leadingComments": null }, "init": { "type": "ArrowFunctionExpression", "start": 655, "end": 1215, "loc": { "start": { "line": 14, "column": 25 }, "end": { "line": 34, "column": 1 } }, "id": null, "generator": false, "expression": false, "async": true, "params": [ { "type": "Identifier", "start": 662, "end": 665, "loc": { "start": { "line": 14, "column": 32 }, "end": { "line": 14, "column": 35 }, "identifierName": "url" }, "name": "url" }, { "type": "Identifier", "start": 667, "end": 673, "loc": { "start": { "line": 14, "column": 37 }, "end": { "line": 14, "column": 43 }, "identifierName": "wallet" }, "name": "wallet" }, { "type": "Identifier", "start": 675, "end": 681, "loc": { "start": { "line": 14, "column": 45 }, "end": { "line": 14, "column": 51 }, "identifierName": "apiKey" }, "name": "apiKey" }, { "type": "Identifier", "start": 683, "end": 696, "loc": { "start": { "line": 14, "column": 53 }, "end": { "line": 14, "column": 66 }, "identifierName": "managementKey" }, "name": "managementKey" } ], "body": { "type": "BlockStatement", "start": 701, "end": 1215, "loc": { "start": { "line": 14, "column": 71 }, "end": { "line": 34, "column": 1 } }, "body": [ { "type": "IfStatement", "start": 711, "end": 1213, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 33, "column": 9 } }, "test": { "type": "CallExpression", "start": 714, "end": 758, "loc": { "start": { "line": 15, "column": 11 }, "end": { "line": 15, "column": 55 } }, "callee": { "type": "MemberExpression", "start": 714, "end": 728, "loc": { "start": { "line": 15, "column": 11 }, "end": { "line": 15, "column": 25 } }, "object": { "type": "Identifier", "start": 714, "end": 717, "loc": { "start": { "line": 15, "column": 11 }, "end": { "line": 15, "column": 14 }, "identifierName": "url" }, "name": "url" }, "property": { "type": "Identifier", "start": 718, "end": 728, "loc": { "start": { "line": 15, "column": 15 }, "end": { "line": 15, "column": 25 }, "identifierName": "startsWith" }, "name": "startsWith" }, "computed": false }, "arguments": [ { "type": "StringLiteral", "start": 729, "end": 757, "loc": { "start": { "line": 15, "column": 26 }, "end": { "line": 15, "column": 54 } }, "extra": { "rawValue": "https://api.simbachain.com", "raw": "'https://api.simbachain.com'" }, "value": "https://api.simbachain.com" } ] }, "consequent": { "type": "BlockStatement", "start": 759, "end": 1087, "loc": { "start": { "line": 15, "column": 56 }, "end": { "line": 30, "column": 9 } }, "body": [ { "type": "VariableDeclaration", "start": 792, "end": 832, "loc": { "start": { "line": 17, "column": 12 }, "end": { "line": 17, "column": 52 } }, "declarations": [ { "type": "VariableDeclarator", "start": 796, "end": 831, "loc": { "start": { "line": 17, "column": 16 }, "end": { "line": 17, "column": 51 } }, "id": { "type": "Identifier", "start": 796, "end": 801, "loc": { "start": { "line": 17, "column": 16 }, "end": { "line": 17, "column": 21 }, "identifierName": "simba" }, "name": "simba", "leadingComments": null }, "init": { "type": "NewExpression", "start": 804, "end": 831, "loc": { "start": { "line": 17, "column": 24 }, "end": { "line": 17, "column": 51 } }, "callee": { "type": "Identifier", "start": 808, "end": 818, "loc": { "start": { "line": 17, "column": 28 }, "end": { "line": 17, "column": 38 }, "identifierName": "Simbachain" }, "name": "Simbachain" }, "arguments": [ { "type": "Identifier", "start": 819, "end": 822, "loc": { "start": { "line": 17, "column": 39 }, "end": { "line": 17, "column": 42 }, "identifierName": "url" }, "name": "url" }, { "type": "Identifier", "start": 824, "end": 830, "loc": { "start": { "line": 17, "column": 44 }, "end": { "line": 17, "column": 50 }, "identifierName": "wallet" }, "name": "wallet" } ] }, "leadingComments": null } ], "kind": "let", "leadingComments": [ { "type": "CommentLine", "value": ".com", "start": 773, "end": 779, "loc": { "start": { "line": 16, "column": 12 }, "end": { "line": 16, "column": 18 } } } ] }, { "type": "IfStatement", "start": 846, "end": 911, "loc": { "start": { "line": 19, "column": 12 }, "end": { "line": 21, "column": 13 } }, "test": { "type": "Identifier", "start": 849, "end": 855, "loc": { "start": { "line": 19, "column": 15 }, "end": { "line": 19, "column": 21 }, "identifierName": "apiKey" }, "name": "apiKey" }, "consequent": { "type": "BlockStatement", "start": 856, "end": 911, "loc": { "start": { "line": 19, "column": 22 }, "end": { "line": 21, "column": 13 } }, "body": [ { "type": "ExpressionStatement", "start": 874, "end": 897, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 39 } }, "expression": { "type": "CallExpression", "start": 874, "end": 897, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 39 } }, "callee": { "type": "MemberExpression", "start": 874, "end": 889, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 31 } }, "object": { "type": "Identifier", "start": 874, "end": 879, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 21 }, "identifierName": "simba" }, "name": "simba" }, "property": { "type": "Identifier", "start": 880, "end": 889, "loc": { "start": { "line": 20, "column": 22 }, "end": { "line": 20, "column": 31 }, "identifierName": "setApiKey" }, "name": "setApiKey" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 890, "end": 896, "loc": { "start": { "line": 20, "column": 32 }, "end": { "line": 20, "column": 38 }, "identifierName": "apiKey" }, "name": "apiKey" } ] } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 925, "end": 1011, "loc": { "start": { "line": 23, "column": 12 }, "end": { "line": 25, "column": 13 } }, "test": { "type": "Identifier", "start": 928, "end": 941, "loc": { "start": { "line": 23, "column": 15 }, "end": { "line": 23, "column": 28 }, "identifierName": "managementKey" }, "name": "managementKey" }, "consequent": { "type": "BlockStatement", "start": 942, "end": 1011, "loc": { "start": { "line": 23, "column": 29 }, "end": { "line": 25, "column": 13 } }, "body": [ { "type": "ExpressionStatement", "start": 960, "end": 997, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 24, "column": 53 } }, "expression": { "type": "CallExpression", "start": 960, "end": 997, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 24, "column": 53 } }, "callee": { "type": "MemberExpression", "start": 960, "end": 982, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 24, "column": 38 } }, "object": { "type": "Identifier", "start": 960, "end": 965, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 24, "column": 21 }, "identifierName": "simba" }, "name": "simba" }, "property": { "type": "Identifier", "start": 966, "end": 982, "loc": { "start": { "line": 24, "column": 22 }, "end": { "line": 24, "column": 38 }, "identifierName": "setManagementKey" }, "name": "setManagementKey" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 983, "end": 996, "loc": { "start": { "line": 24, "column": 39 }, "end": { "line": 24, "column": 52 }, "identifierName": "managementKey" }, "name": "managementKey" } ] } } ], "directives": [] }, "alternate": null }, { "type": "ExpressionStatement", "start": 1025, "end": 1050, "loc": { "start": { "line": 27, "column": 12 }, "end": { "line": 27, "column": 37 } }, "expression": { "type": "AwaitExpression", "start": 1025, "end": 1049, "loc": { "start": { "line": 27, "column": 12 }, "end": { "line": 27, "column": 36 } }, "argument": { "type": "CallExpression", "start": 1031, "end": 1049, "loc": { "start": { "line": 27, "column": 18 }, "end": { "line": 27, "column": 36 } }, "callee": { "type": "MemberExpression", "start": 1031, "end": 1047, "loc": { "start": { "line": 27, "column": 18 }, "end": { "line": 27, "column": 34 } }, "object": { "type": "Identifier", "start": 1031, "end": 1036, "loc": { "start": { "line": 27, "column": 18 }, "end": { "line": 27, "column": 23 }, "identifierName": "simba" }, "name": "simba" }, "property": { "type": "Identifier", "start": 1037, "end": 1047, "loc": { "start": { "line": 27, "column": 24 }, "end": { "line": 27, "column": 34 }, "identifierName": "initialize" }, "name": "initialize" }, "computed": false }, "arguments": [] } } }, { "type": "ReturnStatement", "start": 1064, "end": 1077, "loc": { "start": { "line": 29, "column": 12 }, "end": { "line": 29, "column": 25 } }, "argument": { "type": "Identifier", "start": 1071, "end": 1076, "loc": { "start": { "line": 29, "column": 19 }, "end": { "line": 29, "column": 24 }, "identifierName": "simba" }, "name": "simba" } } ], "directives": [] }, "alternate": { "type": "BlockStatement", "start": 1091, "end": 1213, "loc": { "start": { "line": 30, "column": 13 }, "end": { "line": 33, "column": 9 } }, "body": [ { "type": "ThrowStatement", "start": 1125, "end": 1203, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 90 } }, "argument": { "type": "NewExpression", "start": 1131, "end": 1203, "loc": { "start": { "line": 32, "column": 18 }, "end": { "line": 32, "column": 90 } }, "callee": { "type": "Identifier", "start": 1135, "end": 1158, "loc": { "start": { "line": 32, "column": 22 }, "end": { "line": 32, "column": 45 }, "identifierName": "NotImplementedException" }, "name": "NotImplementedException" }, "arguments": [ { "type": "StringLiteral", "start": 1159, "end": 1202, "loc": { "start": { "line": 32, "column": 46 }, "end": { "line": 32, "column": 89 } }, "extra": { "rawValue": "SCaaS Support not yet implemented, sorry.", "raw": "\"SCaaS Support not yet implemented, sorry.\"" }, "value": "SCaaS Support not yet implemented, sorry." } ], "leadingComments": null }, "leadingComments": [ { "type": "CommentLine", "value": "scaas", "start": 1105, "end": 1112, "loc": { "start": {