@ocap/client 1.6.3 → 1.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +1 -1
  2. package/dist/base.js +36 -22
  3. package/dist/base.js.map +1 -1
  4. package/dist/browser.d.ts +997 -590
  5. package/dist/browser.js +1 -8
  6. package/dist/browser.js.map +1 -1
  7. package/dist/bundle.js +3 -3
  8. package/dist/client.js +11 -7
  9. package/dist/client.js.map +1 -1
  10. package/dist/extension.js +502 -462
  11. package/dist/extension.js.map +1 -1
  12. package/dist/methods.js +0 -142
  13. package/dist/methods.js.map +1 -1
  14. package/dist/report.html +2 -2
  15. package/dist/schema/graphql.json +9048 -4442
  16. package/dist/schema/graphql.txt +2 -2
  17. package/dist/types.js +2143 -1924
  18. package/dist/types.js.map +1 -1
  19. package/docs/QUERIES.md +1547 -1494
  20. package/docs/README.md +3269 -3138
  21. package/examples/asset.js +7 -7
  22. package/examples/create-secondary-token.js +44 -0
  23. package/examples/declare.js +9 -9
  24. package/examples/{delegate_exchange_both.js → delegate-exchange-both.js} +12 -8
  25. package/examples/{delegate_exchange.js → delegate-exchange.js} +11 -7
  26. package/examples/{delegate_transfer.js → delegate-transfer.js} +12 -6
  27. package/examples/exchange-secondary-token.js +100 -0
  28. package/examples/exchange.js +9 -9
  29. package/examples/{migrate_account.js → migrate-account.js} +5 -5
  30. package/examples/run-no-debug.sh +8 -8
  31. package/examples/run.sh +8 -8
  32. package/examples/subscribe.js +16 -0
  33. package/examples/{transfer_asset.js → transfer-asset.js} +11 -11
  34. package/examples/{transfer_token.js → transfer-primary-token.js} +10 -10
  35. package/examples/transfer-secondary-token.js +62 -0
  36. package/lib/base.js +36 -22
  37. package/lib/base.js.map +1 -1
  38. package/lib/client.js +11 -7
  39. package/lib/client.js.map +1 -1
  40. package/lib/extension.js +502 -462
  41. package/lib/extension.js.map +1 -1
  42. package/lib/methods.js +0 -142
  43. package/lib/methods.js.map +1 -1
  44. package/lib/node.d.ts +997 -590
  45. package/lib/node.js +0 -6
  46. package/lib/node.js.map +1 -1
  47. package/lib/schema/graphql.json +9048 -4442
  48. package/lib/schema/graphql.txt +2 -2
  49. package/lib/types.js +2143 -1924
  50. package/lib/types.js.map +1 -1
  51. package/package.json +30 -32
  52. package/examples/atomic_swap.js +0 -145
  53. package/examples/consume_asset_gatekeeper.js +0 -105
  54. package/examples/consume_asset_simple.js +0 -91
  55. package/examples/declare_forgeweb.js +0 -60
  56. package/examples/declare_restricted.js +0 -47
  57. package/examples/delegate_atomic_swap.js +0 -177
  58. package/examples/get_free_token.js +0 -33
  59. package/examples/subscribe_new_block.js +0 -36
  60. package/examples/subscribe_transfer.js +0 -80
package/dist/client.js CHANGED
@@ -10,8 +10,7 @@ const GraphQLClientBase = require('./base');
10
10
  * @example
11
11
  * const GraphQLClient = require('@ocap/client');
12
12
  *
13
- * const client = new GraphQLClient('https://argon.abtnetwork.io/api');
14
- * // const client = new GraphQLClient({ endpoint: 'https://argon.abtnetwork.io/api' });
13
+ * const client = new GraphQLClient('https://beta.abtnetwork.io/api');
15
14
  *
16
15
  * const res = await client.getChainInfo();
17
16
  */
@@ -20,18 +19,23 @@ class GraphQLClient extends GraphQLClientBase {
20
19
  * Create an instance of GraphQLClient
21
20
  *
22
21
  * @constructor
23
- * @param {object|string} config - config object, if a string passed, will be used as the endpoint
24
- * @param {string} [config.endpoint='http://localhost:8210/api'] - the graphql endpoint
25
- * @param {string} [config.chainId=''] - the chainId of the network
22
+ * @param {string} [endpoint='http://localhost:8210/api'] - the graphql endpoint
26
23
  * @see GraphQLClient#getQueries
27
24
  * @see GraphQLClient#getMutations
28
25
  * @see GraphQLClient#getSubscriptions
29
26
  * @see GraphQLClient#getTxSendMethods
30
27
  * @see GraphQLClient#getTxEncodeMethods
31
28
  */
32
- constructor(config = 'http://localhost:8210/api') {
33
- super(config);
29
+ constructor(endpoint = 'http://localhost:8210/api/gql', autoInit = true) {
30
+ super(endpoint);
34
31
  createExtensionMethods(this, { encodeTxAsBase64: true });
32
+
33
+ // warmup the context
34
+ if (autoInit) {
35
+ this.getContext().catch(err => {
36
+ console.warn('failed to warmup context', err.message);
37
+ });
38
+ }
35
39
  }
36
40
  }
37
41
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.js"],"names":["createExtensionMethods","require","GraphQLClientBase","GraphQLClient","constructor","config","encodeTxAsBase64","module","exports"],"mappings":"AAAA,MAAM,EAAEA,sBAAF,KAA6BC,QAAQ,aAAR,CAAnC;AACA,MAAMC,oBAAoBD,QAAQ,QAAR,CAA1B;;AAEA;;;;;;;;;;;;;;AAcA,MAAME,aAAN,SAA4BD,iBAA5B,CAA8C;AAC5C;;;;;;;;;;;;;AAaAE,cAAYC,SAAS,2BAArB,EAAkD;AAChD,UAAMA,MAAN;AACAL,2BAAuB,IAAvB,EAA6B,EAAEM,kBAAkB,IAApB,EAA7B;AACD;AAjB2C;;AAoB9CC,OAAOC,OAAP,GAAiBL,aAAjB","file":"client.js","sourcesContent":["const { createExtensionMethods } = require('./extension');\nconst GraphQLClientBase = require('./base');\n\n/**\n * An http client that can read/write data to a forge powered blockchain node, can be used in both node.js and browser.\n *\n * Please note that, due to internal implementation of google-protobuf, all `repeated fields` names are suffixed with `List`\n *\n * @class\n * @example\n * const GraphQLClient = require('@ocap/client');\n *\n * const client = new GraphQLClient('https://argon.abtnetwork.io/api');\n * // const client = new GraphQLClient({ endpoint: 'https://argon.abtnetwork.io/api' });\n *\n * const res = await client.getChainInfo();\n */\nclass GraphQLClient extends GraphQLClientBase {\n /**\n * Create an instance of GraphQLClient\n *\n * @constructor\n * @param {object|string} config - config object, if a string passed, will be used as the endpoint\n * @param {string} [config.endpoint='http://localhost:8210/api'] - the graphql endpoint\n * @param {string} [config.chainId=''] - the chainId of the network\n * @see GraphQLClient#getQueries\n * @see GraphQLClient#getMutations\n * @see GraphQLClient#getSubscriptions\n * @see GraphQLClient#getTxSendMethods\n * @see GraphQLClient#getTxEncodeMethods\n */\n constructor(config = 'http://localhost:8210/api') {\n super(config);\n createExtensionMethods(this, { encodeTxAsBase64: true });\n }\n}\n\nmodule.exports = GraphQLClient;\n"]}
1
+ {"version":3,"sources":["../src/client.js"],"names":["createExtensionMethods","require","GraphQLClientBase","GraphQLClient","constructor","endpoint","autoInit","encodeTxAsBase64","getContext","catch","err","console","warn","message","module","exports"],"mappings":"AAAA,MAAM,EAAEA,sBAAF,KAA6BC,QAAQ,aAAR,CAAnC;AACA,MAAMC,oBAAoBD,QAAQ,QAAR,CAA1B;;AAEA;;;;;;;;;;;;;AAaA,MAAME,aAAN,SAA4BD,iBAA5B,CAA8C;AAC5C;;;;;;;;;;;AAWAE,cAAYC,WAAW,+BAAvB,EAAwDC,WAAW,IAAnE,EAAyE;AACvE,UAAMD,QAAN;AACAL,2BAAuB,IAAvB,EAA6B,EAAEO,kBAAkB,IAApB,EAA7B;;AAEA;AACA,QAAID,QAAJ,EAAc;AACZ,WAAKE,UAAL,GAAkBC,KAAlB,CAAyBC,GAAD,IAAS;AAC/BC,gBAAQC,IAAR,CAAa,0BAAb,EAAyCF,IAAIG,OAA7C;AACD,OAFD;AAGD;AACF;AAtB2C;;AAyB9CC,OAAOC,OAAP,GAAiBZ,aAAjB","file":"client.js","sourcesContent":["const { createExtensionMethods } = require('./extension');\nconst GraphQLClientBase = require('./base');\n\n/**\n * An http client that can read/write data to a forge powered blockchain node, can be used in both node.js and browser.\n *\n * Please note that, due to internal implementation of google-protobuf, all `repeated fields` names are suffixed with `List`\n *\n * @class\n * @example\n * const GraphQLClient = require('@ocap/client');\n *\n * const client = new GraphQLClient('https://beta.abtnetwork.io/api');\n *\n * const res = await client.getChainInfo();\n */\nclass GraphQLClient extends GraphQLClientBase {\n /**\n * Create an instance of GraphQLClient\n *\n * @constructor\n * @param {string} [endpoint='http://localhost:8210/api'] - the graphql endpoint\n * @see GraphQLClient#getQueries\n * @see GraphQLClient#getMutations\n * @see GraphQLClient#getSubscriptions\n * @see GraphQLClient#getTxSendMethods\n * @see GraphQLClient#getTxEncodeMethods\n */\n constructor(endpoint = 'http://localhost:8210/api/gql', autoInit = true) {\n super(endpoint);\n createExtensionMethods(this, { encodeTxAsBase64: true });\n\n // warmup the context\n if (autoInit) {\n this.getContext().catch((err) => {\n console.warn('failed to warmup context', err.message);\n });\n }\n }\n}\n\nmodule.exports = GraphQLClient;\n"]}