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,435 lines (1,434 loc) 166 kB
{ "type": "File", "start": 0, "end": 1367, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 44, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 1367, "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": 48, "end": 103, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 55 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 56, "end": 62, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 14 } }, "imported": { "type": "Identifier", "start": 56, "end": 62, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 14 }, "identifierName": "Wallet" }, "name": "Wallet" }, "local": { "type": "Identifier", "start": 56, "end": 62, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 14 }, "identifierName": "Wallet" }, "name": "Wallet" } }, { "type": "ImportSpecifier", "start": 64, "end": 75, "loc": { "start": { "line": 2, "column": 16 }, "end": { "line": 2, "column": 27 } }, "imported": { "type": "Identifier", "start": 64, "end": 75, "loc": { "start": { "line": 2, "column": 16 }, "end": { "line": 2, "column": 27 }, "identifierName": "LocalWallet" }, "name": "LocalWallet" }, "local": { "type": "Identifier", "start": 64, "end": 75, "loc": { "start": { "line": 2, "column": 16 }, "end": { "line": 2, "column": 27 }, "identifierName": "LocalWallet" }, "name": "LocalWallet" } }, { "type": "ImportSpecifier", "start": 77, "end": 85, "loc": { "start": { "line": 2, "column": 29 }, "end": { "line": 2, "column": 37 } }, "imported": { "type": "Identifier", "start": 77, "end": 85, "loc": { "start": { "line": 2, "column": 29 }, "end": { "line": 2, "column": 37 }, "identifierName": "PKWallet" }, "name": "PKWallet" }, "local": { "type": "Identifier", "start": 77, "end": 85, "loc": { "start": { "line": 2, "column": 29 }, "end": { "line": 2, "column": 37 }, "identifierName": "PKWallet" }, "name": "PKWallet" } } ], "source": { "type": "StringLiteral", "start": 92, "end": 102, "loc": { "start": { "line": 2, "column": 44 }, "end": { "line": 2, "column": 54 } }, "extra": { "rawValue": "./wallet", "raw": "'./wallet'" }, "value": "./wallet" } }, { "type": "ImportDeclaration", "start": 105, "end": 158, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 53 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 113, "end": 136, "loc": { "start": { "line": 3, "column": 8 }, "end": { "line": 3, "column": 31 } }, "imported": { "type": "Identifier", "start": 113, "end": 136, "loc": { "start": { "line": 3, "column": 8 }, "end": { "line": 3, "column": 31 }, "identifierName": "NotImplementedException" }, "name": "NotImplementedException" }, "local": { "type": "Identifier", "start": 113, "end": 136, "loc": { "start": { "line": 3, "column": 8 }, "end": { "line": 3, "column": 31 }, "identifierName": "NotImplementedException" }, "name": "NotImplementedException" } } ], "source": { "type": "StringLiteral", "start": 143, "end": 157, "loc": { "start": { "line": 3, "column": 38 }, "end": { "line": 3, "column": 52 } }, "extra": { "rawValue": "./exceptions", "raw": "'./exceptions'" }, "value": "./exceptions" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\r\n * Create an instance of a Simbachain API interaction class\r\n * Automatically takes care of choosing the correct implementation and running asynchronous initialisation.\r\n * @param {string} url - The API URL\r\n * @param {Wallet} wallet - The Wallet to use\r\n * @param {string} [apiKey] - (Optional) The API key\r\n * @param {string} [managementKey] - (Optional) The Management API key\r\n * @returns {Promise<Simbachain>} - An initialised instance of the API interaction class\r\n ", "start": 162, "end": 641, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 13, "column": 3 } } } ] }, { "type": "Identifier", "start": 643, "end": 1249, "loc": { "start": { "line": 14, "column": 0 }, "end": { "line": 34, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 649, "end": 1248, "loc": { "start": { "line": 14, "column": 6 }, "end": { "line": 34, "column": 1 } }, "id": { "type": "Identifier", "start": 649, "end": 665, "loc": { "start": { "line": 14, "column": 6 }, "end": { "line": 14, "column": 22 }, "identifierName": "getSimbaInstance" }, "name": "getSimbaInstance", "leadingComments": null }, "init": { "type": "ArrowFunctionExpression", "start": 668, "end": 1248, "loc": { "start": { "line": 14, "column": 25 }, "end": { "line": 34, "column": 1 } }, "id": null, "generator": false, "expression": false, "async": true, "params": [ { "type": "Identifier", "start": 675, "end": 678, "loc": { "start": { "line": 14, "column": 32 }, "end": { "line": 14, "column": 35 }, "identifierName": "url" }, "name": "url" }, { "type": "Identifier", "start": 680, "end": 686, "loc": { "start": { "line": 14, "column": 37 }, "end": { "line": 14, "column": 43 }, "identifierName": "wallet" }, "name": "wallet" }, { "type": "Identifier", "start": 688, "end": 694, "loc": { "start": { "line": 14, "column": 45 }, "end": { "line": 14, "column": 51 }, "identifierName": "apiKey" }, "name": "apiKey" }, { "type": "Identifier", "start": 696, "end": 709, "loc": { "start": { "line": 14, "column": 53 }, "end": { "line": 14, "column": 66 }, "identifierName": "managementKey" }, "name": "managementKey" } ], "body": { "type": "BlockStatement", "start": 714, "end": 1248, "loc": { "start": { "line": 14, "column": 71 }, "end": { "line": 34, "column": 1 } }, "body": [ { "type": "IfStatement", "start": 725, "end": 1245, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 33, "column": 9 } }, "test": { "type": "CallExpression", "start": 728, "end": 772, "loc": { "start": { "line": 15, "column": 11 }, "end": { "line": 15, "column": 55 } }, "callee": { "type": "MemberExpression", "start": 728, "end": 742, "loc": { "start": { "line": 15, "column": 11 }, "end": { "line": 15, "column": 25 } }, "object": { "type": "Identifier", "start": 728, "end": 731, "loc": { "start": { "line": 15, "column": 11 }, "end": { "line": 15, "column": 14 }, "identifierName": "url" }, "name": "url" }, "property": { "type": "Identifier", "start": 732, "end": 742, "loc": { "start": { "line": 15, "column": 15 }, "end": { "line": 15, "column": 25 }, "identifierName": "startsWith" }, "name": "startsWith" }, "computed": false }, "arguments": [ { "type": "StringLiteral", "start": 743, "end": 771, "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": 773, "end": 1116, "loc": { "start": { "line": 15, "column": 56 }, "end": { "line": 30, "column": 9 } }, "body": [ { "type": "VariableDeclaration", "start": 808, "end": 848, "loc": { "start": { "line": 17, "column": 12 }, "end": { "line": 17, "column": 52 } }, "declarations": [ { "type": "VariableDeclarator", "start": 812, "end": 847, "loc": { "start": { "line": 17, "column": 16 }, "end": { "line": 17, "column": 51 } }, "id": { "type": "Identifier", "start": 812, "end": 817, "loc": { "start": { "line": 17, "column": 16 }, "end": { "line": 17, "column": 21 }, "identifierName": "simba" }, "name": "simba", "leadingComments": null }, "init": { "type": "NewExpression", "start": 820, "end": 847, "loc": { "start": { "line": 17, "column": 24 }, "end": { "line": 17, "column": 51 } }, "callee": { "type": "Identifier", "start": 824, "end": 834, "loc": { "start": { "line": 17, "column": 28 }, "end": { "line": 17, "column": 38 }, "identifierName": "Simbachain" }, "name": "Simbachain" }, "arguments": [ { "type": "Identifier", "start": 835, "end": 838, "loc": { "start": { "line": 17, "column": 39 }, "end": { "line": 17, "column": 42 }, "identifierName": "url" }, "name": "url" }, { "type": "Identifier", "start": 840, "end": 846, "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": 788, "end": 794, "loc": { "start": { "line": 16, "column": 12 }, "end": { "line": 16, "column": 18 } } } ] }, { "type": "IfStatement", "start": 864, "end": 931, "loc": { "start": { "line": 19, "column": 12 }, "end": { "line": 21, "column": 13 } }, "test": { "type": "Identifier", "start": 867, "end": 873, "loc": { "start": { "line": 19, "column": 15 }, "end": { "line": 19, "column": 21 }, "identifierName": "apiKey" }, "name": "apiKey" }, "consequent": { "type": "BlockStatement", "start": 874, "end": 931, "loc": { "start": { "line": 19, "column": 22 }, "end": { "line": 21, "column": 13 } }, "body": [ { "type": "ExpressionStatement", "start": 893, "end": 916, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 39 } }, "expression": { "type": "CallExpression", "start": 893, "end": 916, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 39 } }, "callee": { "type": "MemberExpression", "start": 893, "end": 908, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 31 } }, "object": { "type": "Identifier", "start": 893, "end": 898, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 21 }, "identifierName": "simba" }, "name": "simba" }, "property": { "type": "Identifier", "start": 899, "end": 908, "loc": { "start": { "line": 20, "column": 22 }, "end": { "line": 20, "column": 31 }, "identifierName": "setApiKey" }, "name": "setApiKey" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 909, "end": 915, "loc": { "start": { "line": 20, "column": 32 }, "end": { "line": 20, "column": 38 }, "identifierName": "apiKey" }, "name": "apiKey" } ] } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 947, "end": 1035, "loc": { "start": { "line": 23, "column": 12 }, "end": { "line": 25, "column": 13 } }, "test": { "type": "Identifier", "start": 950, "end": 963, "loc": { "start": { "line": 23, "column": 15 }, "end": { "line": 23, "column": 28 }, "identifierName": "managementKey" }, "name": "managementKey" }, "consequent": { "type": "BlockStatement", "start": 964, "end": 1035, "loc": { "start": { "line": 23, "column": 29 }, "end": { "line": 25, "column": 13 } }, "body": [ { "type": "ExpressionStatement", "start": 983, "end": 1020, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 24, "column": 53 } }, "expression": { "type": "CallExpression", "start": 983, "end": 1020, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 24, "column": 53 } }, "callee": { "type": "MemberExpression", "start": 983, "end": 1005, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 24, "column": 38 } }, "object": { "type": "Identifier", "start": 983, "end": 988, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 24, "column": 21 }, "identifierName": "simba" }, "name": "simba" }, "property": { "type": "Identifier", "start": 989, "end": 1005, "loc": { "start": { "line": 24, "column": 22 }, "end": { "line": 24, "column": 38 }, "identifierName": "setManagementKey" }, "name": "setManagementKey" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 1006, "end": 1019, "loc": { "start": { "line": 24, "column": 39 }, "end": { "line": 24, "column": 52 }, "identifierName": "managementKey" }, "name": "managementKey" } ] } } ], "directives": [] }, "alternate": null }, { "type": "ExpressionStatement", "start": 1051, "end": 1076, "loc": { "start": { "line": 27, "column": 12 }, "end": { "line": 27, "column": 37 } }, "expression": { "type": "AwaitExpression", "start": 1051, "end": 1075, "loc": { "start": { "line": 27, "column": 12 }, "end": { "line": 27, "column": 36 } }, "argument": { "type": "CallExpression", "start": 1057, "end": 1075, "loc": { "start": { "line": 27, "column": 18 }, "end": { "line": 27, "column": 36 } }, "callee": { "type": "MemberExpression", "start": 1057, "end": 1073, "loc": { "start": { "line": 27, "column": 18 }, "end": { "line": 27, "column": 34 } }, "object": { "type": "Identifier", "start": 1057, "end": 1062, "loc": { "start": { "line": 27, "column": 18 }, "end": { "line": 27, "column": 23 }, "identifierName": "simba" }, "name": "simba" }, "property": { "type": "Identifier", "start": 1063, "end": 1073, "loc": { "start": { "line": 27, "column": 24 }, "end": { "line": 27, "column": 34 }, "identifierName": "initialize" }, "name": "initialize" }, "computed": false }, "arguments": [] } } }, { "type": "ReturnStatement", "start": 1092, "end": 1105, "loc": { "start": { "line": 29, "column": 12 }, "end": { "line": 29, "column": 25 } }, "argument": { "type": "Identifier", "start": 1099, "end": 1104, "loc": { "start": { "line": 29, "column": 19 }, "end": { "line": 29, "column": 24 }, "identifierName": "simba" }, "name": "simba" } } ], "directives": [] }, "alternate": { "type": "BlockStatement", "start": 1120, "end": 1245, "loc": { "start": { "line": 30, "column": 13 }, "end": { "line": 33, "column": 9 } }, "body": [ { "type": "ThrowStatement", "start": 1156, "end": 1234, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 90 } }, "argument": { "type": "NewExpression", "start": 1162, "end": 1234, "loc": { "start": { "line": 32, "column": 18 }, "end": { "line": 32, "column": 90 } }, "callee": { "type": "Identifier", "start": 1166, "end": 1189, "loc": { "start": { "line": 32, "column": 22 }, "end": { "line": 32, "column": 45 }, "identifierName": "NotImplementedException" }, "name": "NotImplementedException" }, "arguments": [ { "type": "StringLiteral", "start": 1190, "end": 1233, "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": 1135, "end": 1142, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 31, "column": 19 } } } ] } ], "directives": [] } } ], "directives": [] } }, "leadingComments": null } ], "kind": "const", "leadingComments": [], "name": "_", "trailingComments": [] }, { "type": "ExportNamedDeclaration", "start": 1253, "end": 1365, "loc": { "start": { "line": 36, "column": 0 }, "end": { "line": 43, "column": 1 } }, "declaration": null, "specifiers": [ { "type": "ExportSpecifier", "start": 1267, "end": 1276, "loc": { "start": { "line": 37, "column": 4 }, "end": { "line": 37,