@ark-us/wasmx-stargate 0.0.10 → 0.0.12

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 (48) hide show
  1. package/LICENSE +674 -0
  2. package/build/index.d.ts +1 -0
  3. package/build/index.js +5 -1
  4. package/build/index.js.map +1 -1
  5. package/build/modules/wasmx/aminomessages.d.ts +3 -3
  6. package/build/modules/wasmx/aminomessages.js +4 -4
  7. package/build/modules/wasmx/aminomessages.js.map +1 -1
  8. package/build/modules/wasmx/utils.d.ts +11 -0
  9. package/build/modules/wasmx/utils.js +43 -0
  10. package/build/modules/wasmx/utils.js.map +1 -0
  11. package/build/signingwasmxclient.js +14 -16
  12. package/build/signingwasmxclient.js.map +1 -1
  13. package/build/tendermintclient.d.ts +4 -2
  14. package/build/tendermintclient.js +8 -1
  15. package/build/tendermintclient.js.map +1 -1
  16. package/build/wasmxclient.d.ts +3 -4
  17. package/build/wasmxclient.js +4 -33
  18. package/build/wasmxclient.js.map +1 -1
  19. package/package.json +10 -10
  20. package/.DS_Store +0 -0
  21. package/.eslintignore +0 -5
  22. package/.eslintrc.js +0 -108
  23. package/.gitignore +0 -5
  24. package/build/encoding.spec.d.ts +0 -1
  25. package/build/encoding.spec.js +0 -78
  26. package/build/encoding.spec.js.map +0 -1
  27. package/build/modules/wasmx/aminomessages.spec.d.ts +0 -1
  28. package/build/modules/wasmx/aminomessages.spec.js +0 -242
  29. package/build/modules/wasmx/aminomessages.spec.js.map +0 -1
  30. package/jasmine-testrunner.js +0 -38
  31. package/karma.conf.js +0 -54
  32. package/src/encoding.spec.ts +0 -99
  33. package/src/encoding.ts +0 -21
  34. package/src/index.ts +0 -30
  35. package/src/modules/index.ts +0 -20
  36. package/src/modules/wasmx/aminomessages.spec.ts +0 -258
  37. package/src/modules/wasmx/aminomessages.ts +0 -177
  38. package/src/modules/wasmx/messages.ts +0 -54
  39. package/src/modules/wasmx/queries.ts +0 -141
  40. package/src/signingwasmxclient.ts +0 -660
  41. package/src/tendermintclient.ts +0 -7
  42. package/src/wasmxclient.ts +0 -494
  43. package/tsconfig.eslint.json +0 -9
  44. package/tsconfig.json +0 -12
  45. package/typedoc.js +0 -11
  46. package/webpack.web.config.js +0 -37
  47. package/yarn-error.log +0 -4205
  48. package/yarn.lock +0 -4145
@@ -1,141 +0,0 @@
1
- import { fromUtf8, toUtf8 } from "@cosmjs/encoding";
2
- import { createPagination, createProtobufRpcClient, QueryClient, Coin } from "@cosmjs/stargate";
3
- import {
4
- QueryAllContractStateResponse,
5
- QueryCodeResponse,
6
- QueryCodeInfoResponse,
7
- QueryCodesResponse,
8
- QueryContractInfoResponse,
9
- QueryContractsByCodeResponse,
10
- QueryRawContractStateResponse,
11
- QueryClientImpl,
12
- } from "@ark-us/wasmxjs";
13
- import Long from 'long';
14
-
15
- /**
16
- * An object containing a parsed JSON document. The result of JSON.parse().
17
- * This doesn't provide any type safety over `any` but expresses intent in the code.
18
- *
19
- * This type is returned by `queryContractSmart`.
20
- */
21
- export type JsonObject = any;
22
-
23
- export interface WasmExtension {
24
- readonly wasm: {
25
- readonly listCodeInfo: (paginationKey?: Uint8Array) => Promise<QueryCodesResponse>;
26
- /**
27
- * Downloads the original wasm bytecode by code ID.
28
- *
29
- * Throws an error if no code with this id
30
- */
31
- readonly getCode: (id: number) => Promise<QueryCodeResponse>;
32
- readonly getCodeInfo: (id: number) => Promise<QueryCodeInfoResponse>;
33
- readonly listContractsByCodeId: (
34
- id: number,
35
- paginationKey?: Uint8Array,
36
- ) => Promise<QueryContractsByCodeResponse>;
37
- /**
38
- * Returns null when contract was not found at this address.
39
- */
40
- readonly getContractInfo: (address: string) => Promise<QueryContractInfoResponse>;
41
- /**
42
- * Returns all contract state.
43
- * This is an empty array if no such contract, or contract has no data.
44
- */
45
- readonly getAllContractState: (
46
- address: string,
47
- paginationKey?: Uint8Array,
48
- ) => Promise<QueryAllContractStateResponse>;
49
- /**
50
- * Returns the data at the key if present (unknown decoded json),
51
- * or null if no data at this (contract address, key) pair
52
- */
53
- readonly queryContractRaw: (address: string, key: Uint8Array) => Promise<QueryRawContractStateResponse>;
54
- /**
55
- * Makes a smart query on the contract and parses the response as JSON.
56
- * Throws error if no such contract exists, the query format is invalid or the response is invalid.
57
- */
58
- readonly queryContractSmart: (address: string, query: JsonObject) => Promise<JsonObject>;
59
- readonly queryContractFull: (sender: string, address: string, query: JsonObject, funds: Coin[], dependencies: string[]) => Promise<JsonObject>;
60
- };
61
- }
62
-
63
- export function setupWasmExtension(base: QueryClient): WasmExtension {
64
- const rpc = createProtobufRpcClient(base);
65
- // Use this service to get easy typed access to query methods
66
- // This cannot be used for proof verification
67
- const queryService = new QueryClientImpl(rpc);
68
-
69
- return {
70
- wasm: {
71
- listCodeInfo: async (paginationKey?: Uint8Array) => {
72
- const request = {
73
- pagination: createPagination(paginationKey),
74
- };
75
- // @ts-ignore
76
- return queryService.codes(request);
77
- },
78
- getCode: async (id: number) => {
79
- const request = { codeId: Long.fromNumber(id) };
80
- // @ts-ignore
81
- return queryService.code(request);
82
- },
83
- getCodeInfo: async (id: number) => {
84
- const request = { codeId: Long.fromNumber(id) };
85
- // @ts-ignore
86
- return queryService.codeInfo(request);
87
- },
88
- listContractsByCodeId: async (id: number, paginationKey?: Uint8Array) => {
89
- const request = {
90
- codeId: Long.fromNumber(id),
91
- pagination: createPagination(paginationKey),
92
- };
93
- // @ts-ignore
94
- return queryService.contractsByCode(request);
95
- },
96
- getContractInfo: async (address: string) => {
97
- const request = { address: address };
98
- return queryService.contractInfo(request);
99
- },
100
-
101
- getAllContractState: async (address: string, paginationKey?: Uint8Array) => {
102
- const request = {
103
- address: address,
104
- pagination: createPagination(paginationKey),
105
- };
106
- // @ts-ignore
107
- return queryService.allContractState(request);
108
- },
109
-
110
- queryContractRaw: async (address: string, key: Uint8Array) => {
111
- const request = { address: address, queryData: key };
112
- return queryService.rawContractState(request);
113
- },
114
-
115
- queryContractSmart: async (address: string, query: JsonObject) => {
116
- const request = { address: address, queryData: toUtf8(JSON.stringify(query)) };
117
- const { items } = await queryService.allContractState(request);
118
- return items;
119
- },
120
-
121
- queryContractFull: async (sender: string, address: string, query: JsonObject, funds: Coin[], dependencies: string[]) => {
122
- const request = { sender: sender, address: address, queryData: toUtf8(JSON.stringify(query)), funds: funds, dependencies };
123
- const { data } = await queryService.smartContractCall(request);
124
- // By convention, smart queries must return a valid JSON document (see https://github.com/CosmWasm/cosmwasm/issues/144)
125
- let responseText;
126
- try {
127
- responseText = fromUtf8(data);
128
- }
129
- catch (error) {
130
- throw new Error(`Could not UTF-8 decode smart query response from contract: ${error}`);
131
- }
132
- try {
133
- return JSON.parse(responseText);
134
- }
135
- catch (error) {
136
- throw new Error(`Could not JSON parse smart query response from contract: ${error}`);
137
- }
138
- },
139
- },
140
- };
141
- }