@ark-us/wasmx-stargate 0.0.11 → 0.0.13
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.
- package/LICENSE +674 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +5 -1
- package/build/index.js.map +1 -1
- package/build/modules/wasmx/aminomessages.js +2 -0
- package/build/modules/wasmx/aminomessages.js.map +1 -1
- package/build/signingwasmxclient.js +8 -8
- package/build/signingwasmxclient.js.map +1 -1
- package/build/tendermintclient.d.ts +4 -2
- package/build/tendermintclient.js +8 -1
- package/build/tendermintclient.js.map +1 -1
- package/build/wasmxclient.d.ts +1 -2
- package/build/wasmxclient.js +2 -32
- package/build/wasmxclient.js.map +1 -1
- package/package.json +10 -10
- package/.DS_Store +0 -0
- package/.eslintignore +0 -5
- package/.eslintrc.js +0 -108
- package/.gitignore +0 -5
- package/build/encoding.spec.d.ts +0 -1
- package/build/encoding.spec.js +0 -78
- package/build/encoding.spec.js.map +0 -1
- package/build/modules/wasmx/aminomessages.spec.d.ts +0 -1
- package/build/modules/wasmx/aminomessages.spec.js +0 -242
- package/build/modules/wasmx/aminomessages.spec.js.map +0 -1
- package/jasmine-testrunner.js +0 -38
- package/karma.conf.js +0 -54
- package/src/encoding.spec.ts +0 -99
- package/src/encoding.ts +0 -21
- package/src/index.ts +0 -30
- package/src/modules/index.ts +0 -20
- package/src/modules/wasmx/aminomessages.spec.ts +0 -258
- package/src/modules/wasmx/aminomessages.ts +0 -177
- package/src/modules/wasmx/messages.ts +0 -54
- package/src/modules/wasmx/queries.ts +0 -141
- package/src/modules/wasmx/utils.ts +0 -43
- package/src/signingwasmxclient.ts +0 -658
- package/src/tendermintclient.ts +0 -7
- package/src/wasmxclient.ts +0 -494
- package/tsconfig.eslint.json +0 -9
- package/tsconfig.json +0 -12
- package/typedoc.js +0 -11
- package/webpack.web.config.js +0 -37
- package/yarn-error.log +0 -4205
- package/yarn.lock +0 -4145
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
-
import { fromBase64, toUtf8 } from "@cosmjs/encoding";
|
|
3
|
-
import { AminoTypes, coins } from "@cosmjs/stargate";
|
|
4
|
-
import {
|
|
5
|
-
MsgExecuteContract,
|
|
6
|
-
MsgInstantiateContract,
|
|
7
|
-
MsgStoreCode,
|
|
8
|
-
MsgDeployCode,
|
|
9
|
-
} from "@ark-us/wasmxjs";
|
|
10
|
-
import Long from 'long';
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
AminoMsgExecuteContract,
|
|
14
|
-
AminoMsgInstantiateContract,
|
|
15
|
-
AminoMsgStoreCode,
|
|
16
|
-
AminoMsgDeployCode,
|
|
17
|
-
createWasmAminoConverters,
|
|
18
|
-
} from "./aminomessages";
|
|
19
|
-
|
|
20
|
-
describe("AminoTypes", () => {
|
|
21
|
-
describe("toAmino", () => {
|
|
22
|
-
it("works for MsgStoreCode", () => {
|
|
23
|
-
const msg: MsgStoreCode = {
|
|
24
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
25
|
-
byteCode: fromBase64("WUVMTE9XIFNVQk1BUklORQ=="),
|
|
26
|
-
deps: [],
|
|
27
|
-
};
|
|
28
|
-
const aminoMsg = new AminoTypes(createWasmAminoConverters()).toAmino({
|
|
29
|
-
typeUrl: "/mythos.wasmx.v1.MsgStoreCode",
|
|
30
|
-
value: msg,
|
|
31
|
-
});
|
|
32
|
-
const expected: AminoMsgStoreCode = {
|
|
33
|
-
type: "wasmx/MsgStoreCode",
|
|
34
|
-
value: {
|
|
35
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
36
|
-
byte_code: "WUVMTE9XIFNVQk1BUklORQ==",
|
|
37
|
-
metadata: {name: "", categ: [], icon: "", author: "", site: "", abi: new Uint8Array(0), jsonSchema: ""},
|
|
38
|
-
deps: [],
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
expect(aminoMsg).toEqual(expected);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("works for MsgDeployCode", () => {
|
|
45
|
-
const msg: MsgDeployCode = {
|
|
46
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
47
|
-
byteCode: fromBase64("WUVMTE9XIFNVQk1BUklORQ=="),
|
|
48
|
-
deps: [],
|
|
49
|
-
msg: toUtf8(`{"data":"0x"}`),
|
|
50
|
-
funds: coins(0, "ucosm"),
|
|
51
|
-
label: "label",
|
|
52
|
-
};
|
|
53
|
-
const aminoMsg = new AminoTypes(createWasmAminoConverters()).toAmino({
|
|
54
|
-
typeUrl: "/mythos.wasmx.v1.MsgDeployCode",
|
|
55
|
-
value: msg,
|
|
56
|
-
});
|
|
57
|
-
const expected: AminoMsgDeployCode = {
|
|
58
|
-
type: "wasmx/MsgDeployCode",
|
|
59
|
-
value: {
|
|
60
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
61
|
-
byte_code: "WUVMTE9XIFNVQk1BUklORQ==",
|
|
62
|
-
metadata: {name: "", categ: [], icon: "", author: "", site: "", abi: new Uint8Array(0), jsonSchema: ""},
|
|
63
|
-
deps: [],
|
|
64
|
-
msg: {"data":"0x"},
|
|
65
|
-
funds: coins(0, "ucosm"),
|
|
66
|
-
label: "label",
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
expect(aminoMsg).toEqual(expected);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("works for MsgInstantiateContract", () => {
|
|
73
|
-
// With admin
|
|
74
|
-
{
|
|
75
|
-
const msg: MsgInstantiateContract = {
|
|
76
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
codeId: Long.fromString("12345"),
|
|
79
|
-
label: "sticky",
|
|
80
|
-
msg: toUtf8(`{"foo":"bar"}`),
|
|
81
|
-
funds: coins(1234, "ucosm"),
|
|
82
|
-
};
|
|
83
|
-
const aminoMsg = new AminoTypes(createWasmAminoConverters()).toAmino({
|
|
84
|
-
typeUrl: "/mythos.wasmx.v1.MsgInstantiateContract",
|
|
85
|
-
value: msg,
|
|
86
|
-
});
|
|
87
|
-
const expected: AminoMsgInstantiateContract = {
|
|
88
|
-
type: "wasmx/MsgInstantiateContract",
|
|
89
|
-
value: {
|
|
90
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
91
|
-
code_id: "12345",
|
|
92
|
-
label: "sticky",
|
|
93
|
-
msg: { foo: "bar" },
|
|
94
|
-
funds: coins(1234, "ucosm"),
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
expect(aminoMsg).toEqual(expected);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Without admin
|
|
101
|
-
{
|
|
102
|
-
const msg: MsgInstantiateContract = {
|
|
103
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
104
|
-
// @ts-ignore
|
|
105
|
-
codeId: Long.fromString("12345"),
|
|
106
|
-
label: "sticky",
|
|
107
|
-
msg: toUtf8(`{"foo":"bar"}`),
|
|
108
|
-
funds: coins(1234, "ucosm"),
|
|
109
|
-
};
|
|
110
|
-
const aminoMsg = new AminoTypes(createWasmAminoConverters()).toAmino({
|
|
111
|
-
typeUrl: "/mythos.wasmx.v1.MsgInstantiateContract",
|
|
112
|
-
value: msg,
|
|
113
|
-
});
|
|
114
|
-
const expected: AminoMsgInstantiateContract = {
|
|
115
|
-
type: "wasmx/MsgInstantiateContract",
|
|
116
|
-
value: {
|
|
117
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
118
|
-
code_id: "12345",
|
|
119
|
-
label: "sticky",
|
|
120
|
-
msg: { foo: "bar" },
|
|
121
|
-
funds: coins(1234, "ucosm"),
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
expect(aminoMsg).toEqual(expected);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("works for MsgExecuteContract", () => {
|
|
129
|
-
const msg: MsgExecuteContract = {
|
|
130
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
131
|
-
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
|
132
|
-
msg: toUtf8(`{"foo":"bar"}`),
|
|
133
|
-
funds: coins(1234, "ucosm"),
|
|
134
|
-
dependencies: [],
|
|
135
|
-
};
|
|
136
|
-
const aminoMsg = new AminoTypes(createWasmAminoConverters()).toAmino({
|
|
137
|
-
typeUrl: "/mythos.wasmx.v1.MsgExecuteContract",
|
|
138
|
-
value: msg,
|
|
139
|
-
});
|
|
140
|
-
const expected: AminoMsgExecuteContract = {
|
|
141
|
-
type: "wasmx/MsgExecuteContract",
|
|
142
|
-
value: {
|
|
143
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
144
|
-
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
|
145
|
-
msg: { foo: "bar" },
|
|
146
|
-
funds: coins(1234, "ucosm"),
|
|
147
|
-
dependencies: [],
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
expect(aminoMsg).toEqual(expected);
|
|
151
|
-
});
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
describe("fromAmino", () => {
|
|
155
|
-
it("works for MsgStoreCode", () => {
|
|
156
|
-
const aminoMsg: AminoMsgStoreCode = {
|
|
157
|
-
type: "wasmx/MsgStoreCode",
|
|
158
|
-
value: {
|
|
159
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
160
|
-
byte_code: "WUVMTE9XIFNVQk1BUklORQ==",
|
|
161
|
-
metadata: {name: "", categ: [], icon: "", author: "", site: "", abi: new Uint8Array(0), jsonSchema: ""},
|
|
162
|
-
deps: [],
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
const msg = new AminoTypes(createWasmAminoConverters()).fromAmino(aminoMsg);
|
|
166
|
-
const expectedValue: MsgStoreCode = {
|
|
167
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
168
|
-
byteCode: fromBase64("WUVMTE9XIFNVQk1BUklORQ=="),
|
|
169
|
-
deps: [],
|
|
170
|
-
};
|
|
171
|
-
expect(msg).toEqual({
|
|
172
|
-
typeUrl: "/mythos.wasmx.v1.MsgStoreCode",
|
|
173
|
-
value: expectedValue,
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it("works for MsgInstantiateContract", () => {
|
|
178
|
-
// With admin
|
|
179
|
-
{
|
|
180
|
-
const aminoMsg: AminoMsgInstantiateContract = {
|
|
181
|
-
type: "wasmx/MsgInstantiateContract",
|
|
182
|
-
value: {
|
|
183
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
184
|
-
code_id: "12345",
|
|
185
|
-
label: "sticky",
|
|
186
|
-
msg: { foo: "bar" },
|
|
187
|
-
funds: coins(1234, "ucosm"),
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
const msg = new AminoTypes(createWasmAminoConverters()).fromAmino(aminoMsg);
|
|
191
|
-
const expectedValue: MsgInstantiateContract = {
|
|
192
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
193
|
-
// @ts-ignore
|
|
194
|
-
codeId: Long.fromString("12345"),
|
|
195
|
-
label: "sticky",
|
|
196
|
-
msg: toUtf8(`{"foo":"bar"}`),
|
|
197
|
-
funds: coins(1234, "ucosm"),
|
|
198
|
-
};
|
|
199
|
-
expect(msg).toEqual({
|
|
200
|
-
typeUrl: "/mythos.wasmx.v1.MsgInstantiateContract",
|
|
201
|
-
value: expectedValue,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Without admin
|
|
206
|
-
{
|
|
207
|
-
const aminoMsg: AminoMsgInstantiateContract = {
|
|
208
|
-
type: "wasmx/MsgInstantiateContract",
|
|
209
|
-
value: {
|
|
210
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
211
|
-
code_id: "12345",
|
|
212
|
-
label: "sticky",
|
|
213
|
-
msg: { foo: "bar" },
|
|
214
|
-
funds: coins(1234, "ucosm"),
|
|
215
|
-
},
|
|
216
|
-
};
|
|
217
|
-
const msg = new AminoTypes(createWasmAminoConverters()).fromAmino(aminoMsg);
|
|
218
|
-
const expectedValue: MsgInstantiateContract = {
|
|
219
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
220
|
-
// @ts-ignore
|
|
221
|
-
codeId: Long.fromString("12345"),
|
|
222
|
-
label: "sticky",
|
|
223
|
-
msg: toUtf8(`{"foo":"bar"}`),
|
|
224
|
-
funds: coins(1234, "ucosm"),
|
|
225
|
-
};
|
|
226
|
-
expect(msg).toEqual({
|
|
227
|
-
typeUrl: "/mythos.wasmx.v1.MsgInstantiateContract",
|
|
228
|
-
value: expectedValue,
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it("works for MsgExecuteContract", () => {
|
|
234
|
-
const aminoMsg: AminoMsgExecuteContract = {
|
|
235
|
-
type: "wasmx/MsgExecuteContract",
|
|
236
|
-
value: {
|
|
237
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
238
|
-
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
|
239
|
-
msg: { foo: "bar" },
|
|
240
|
-
funds: coins(1234, "ucosm"),
|
|
241
|
-
dependencies: [],
|
|
242
|
-
},
|
|
243
|
-
};
|
|
244
|
-
const msg = new AminoTypes(createWasmAminoConverters()).fromAmino(aminoMsg);
|
|
245
|
-
const expectedValue: MsgExecuteContract = {
|
|
246
|
-
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
|
247
|
-
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
|
248
|
-
msg: toUtf8(`{"foo":"bar"}`),
|
|
249
|
-
funds: coins(1234, "ucosm"),
|
|
250
|
-
dependencies: [],
|
|
251
|
-
};
|
|
252
|
-
expect(msg).toEqual({
|
|
253
|
-
typeUrl: "/mythos.wasmx.v1.MsgExecuteContract",
|
|
254
|
-
value: expectedValue,
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
});
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
-
import { fromBase64, fromUtf8, toBase64, toUtf8 } from "@cosmjs/encoding";
|
|
3
|
-
import { AminoConverters, Coin } from "@cosmjs/stargate";
|
|
4
|
-
import {
|
|
5
|
-
CodeMetadataPB,
|
|
6
|
-
MsgExecuteContract,
|
|
7
|
-
MsgInstantiateContract,
|
|
8
|
-
MsgStoreCode,
|
|
9
|
-
MsgDeployCode,
|
|
10
|
-
} from "@ark-us/wasmxjs";
|
|
11
|
-
import Long from 'long';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The Amino JSON representation of [MsgStoreCode].
|
|
15
|
-
*/
|
|
16
|
-
export interface AminoMsgStoreCode {
|
|
17
|
-
type: "wasmx/MsgStoreCode";
|
|
18
|
-
value: {
|
|
19
|
-
/** Bech32 account address */
|
|
20
|
-
readonly sender: string;
|
|
21
|
-
/** Base64 encoded Wasm */
|
|
22
|
-
readonly byte_code: string;
|
|
23
|
-
readonly deps: string[];
|
|
24
|
-
readonly metadata: CodeMetadataPB;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The Amino JSON representation of [MsgDeployCode].
|
|
30
|
-
*/
|
|
31
|
-
export interface AminoMsgDeployCode {
|
|
32
|
-
type: "wasmx/MsgDeployCode";
|
|
33
|
-
value: {
|
|
34
|
-
/** Bech32 account address */
|
|
35
|
-
readonly sender: string;
|
|
36
|
-
/** Base64 encoded Wasm */
|
|
37
|
-
readonly byte_code: string;
|
|
38
|
-
readonly deps: string[];
|
|
39
|
-
readonly metadata: CodeMetadataPB;
|
|
40
|
-
/** Instantiate message as JavaScript object */
|
|
41
|
-
readonly msg: any;
|
|
42
|
-
readonly funds: readonly Coin[];
|
|
43
|
-
readonly label: string;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The Amino JSON representation of [MsgExecuteContract].
|
|
49
|
-
*/
|
|
50
|
-
export interface AminoMsgExecuteContract {
|
|
51
|
-
type: "wasmx/MsgExecuteContract";
|
|
52
|
-
value: {
|
|
53
|
-
/** Bech32 account address */
|
|
54
|
-
readonly sender: string;
|
|
55
|
-
/** Bech32 account address */
|
|
56
|
-
readonly contract: string;
|
|
57
|
-
/** Execute message as JavaScript object */
|
|
58
|
-
readonly msg: any;
|
|
59
|
-
readonly funds: readonly Coin[];
|
|
60
|
-
readonly dependencies: string[];
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The Amino JSON representation of [MsgInstantiateContract].
|
|
66
|
-
*/
|
|
67
|
-
export interface AminoMsgInstantiateContract {
|
|
68
|
-
type: "wasmx/MsgInstantiateContract";
|
|
69
|
-
value: {
|
|
70
|
-
/** Bech32 account address */
|
|
71
|
-
readonly sender: string;
|
|
72
|
-
/** ID of the Wasm code that was uploaded before */
|
|
73
|
-
readonly code_id: string;
|
|
74
|
-
/** Human-readable label for this contract */
|
|
75
|
-
readonly label: string;
|
|
76
|
-
/** Instantiate message as JavaScript object */
|
|
77
|
-
readonly msg: any;
|
|
78
|
-
readonly funds: readonly Coin[];
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function createWasmAminoConverters(): AminoConverters {
|
|
83
|
-
return {
|
|
84
|
-
"/mythos.wasmx.v1.MsgStoreCode": {
|
|
85
|
-
aminoType: "wasm/MsgStoreCode",
|
|
86
|
-
toAmino: ({ sender, byteCode, metadata, deps }: MsgStoreCode): AminoMsgStoreCode["value"] => ({
|
|
87
|
-
sender: sender,
|
|
88
|
-
byte_code: toBase64(byteCode),
|
|
89
|
-
metadata: metadata || CodeMetadataPB.fromPartial({}),
|
|
90
|
-
deps: deps,
|
|
91
|
-
}),
|
|
92
|
-
fromAmino: ({ sender, byte_code, deps, metadata }: AminoMsgStoreCode["value"]): MsgStoreCode => ({
|
|
93
|
-
sender: sender,
|
|
94
|
-
byteCode: fromBase64(byte_code),
|
|
95
|
-
deps: deps,
|
|
96
|
-
metadata: metadata || CodeMetadataPB.fromPartial({}),
|
|
97
|
-
}),
|
|
98
|
-
},
|
|
99
|
-
"/mythos.wasmx.v1.MsgDeployCode": {
|
|
100
|
-
aminoType: "wasm/MsgDeployCode",
|
|
101
|
-
toAmino: ({ sender, byteCode, metadata, deps, msg, funds, label }: MsgDeployCode): AminoMsgDeployCode["value"] => ({
|
|
102
|
-
sender: sender,
|
|
103
|
-
byte_code: toBase64(byteCode),
|
|
104
|
-
metadata: metadata || CodeMetadataPB.fromPartial({}),
|
|
105
|
-
deps: deps,
|
|
106
|
-
msg: JSON.parse(fromUtf8(msg)),
|
|
107
|
-
funds: funds,
|
|
108
|
-
label: label,
|
|
109
|
-
}),
|
|
110
|
-
fromAmino: ({ sender, byte_code, metadata, deps, msg, funds, label }: AminoMsgDeployCode["value"]): MsgDeployCode => ({
|
|
111
|
-
sender: sender,
|
|
112
|
-
byteCode: fromBase64(byte_code),
|
|
113
|
-
deps: deps,
|
|
114
|
-
label: label,
|
|
115
|
-
msg: toUtf8(JSON.stringify(msg)),
|
|
116
|
-
funds: [...funds],
|
|
117
|
-
metadata: metadata || CodeMetadataPB.fromPartial({}),
|
|
118
|
-
}),
|
|
119
|
-
},
|
|
120
|
-
"/mythos.wasmx.v1.MsgInstantiateContract": {
|
|
121
|
-
aminoType: "wasm/MsgInstantiateContract",
|
|
122
|
-
toAmino: ({
|
|
123
|
-
sender,
|
|
124
|
-
codeId,
|
|
125
|
-
label,
|
|
126
|
-
msg,
|
|
127
|
-
funds,
|
|
128
|
-
}: MsgInstantiateContract): AminoMsgInstantiateContract["value"] => ({
|
|
129
|
-
sender: sender,
|
|
130
|
-
code_id: codeId.toString(),
|
|
131
|
-
label: label,
|
|
132
|
-
msg: JSON.parse(fromUtf8(msg)),
|
|
133
|
-
funds: funds,
|
|
134
|
-
}),
|
|
135
|
-
fromAmino: ({
|
|
136
|
-
sender,
|
|
137
|
-
code_id,
|
|
138
|
-
label,
|
|
139
|
-
msg,
|
|
140
|
-
funds,
|
|
141
|
-
}: AminoMsgInstantiateContract["value"]): MsgInstantiateContract => ({
|
|
142
|
-
sender: sender,
|
|
143
|
-
// @ts-ignore
|
|
144
|
-
codeId: Long.fromString(code_id),
|
|
145
|
-
label: label,
|
|
146
|
-
msg: toUtf8(JSON.stringify(msg)),
|
|
147
|
-
funds: [...funds],
|
|
148
|
-
}),
|
|
149
|
-
},
|
|
150
|
-
"/mythos.wasmx.v1.MsgExecuteContract": {
|
|
151
|
-
aminoType: "wasm/MsgExecuteContract",
|
|
152
|
-
toAmino: ({ sender, contract, msg, funds, dependencies }: MsgExecuteContract): AminoMsgExecuteContract["value"] => ({
|
|
153
|
-
sender: sender,
|
|
154
|
-
contract: contract,
|
|
155
|
-
msg: JSON.parse(fromUtf8(msg)),
|
|
156
|
-
funds: funds,
|
|
157
|
-
dependencies: dependencies,
|
|
158
|
-
}),
|
|
159
|
-
fromAmino: ({
|
|
160
|
-
sender,
|
|
161
|
-
contract,
|
|
162
|
-
msg,
|
|
163
|
-
funds,
|
|
164
|
-
dependencies,
|
|
165
|
-
}: AminoMsgExecuteContract["value"]): MsgExecuteContract => ({
|
|
166
|
-
sender: sender,
|
|
167
|
-
contract: contract,
|
|
168
|
-
msg: toUtf8(JSON.stringify(msg)),
|
|
169
|
-
funds: [...funds],
|
|
170
|
-
dependencies: [...dependencies]
|
|
171
|
-
}),
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/** @deprecated use `createWasmAminoConverters()` */
|
|
177
|
-
export const wasmXTypes: AminoConverters = createWasmAminoConverters();
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { EncodeObject, GeneratedType } from "@cosmjs/proto-signing";
|
|
2
|
-
import {
|
|
3
|
-
MsgExecuteContract,
|
|
4
|
-
MsgInstantiateContract,
|
|
5
|
-
MsgStoreCode,
|
|
6
|
-
MsgDeployCode,
|
|
7
|
-
} from "@ark-us/wasmxjs";
|
|
8
|
-
|
|
9
|
-
export const wasmTypes: ReadonlyArray<[string, GeneratedType]> = [
|
|
10
|
-
["/mythos.wasmx.v1.MsgExecuteContract", MsgExecuteContract],
|
|
11
|
-
["/mythos.wasmx.v1.MsgStoreCode", MsgStoreCode],
|
|
12
|
-
["/mythos.wasmx.v1.MsgDeployCode", MsgDeployCode],
|
|
13
|
-
["/mythos.wasmx.v1.MsgInstantiateContract", MsgInstantiateContract],
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
export interface MsgStoreCodeEncodeObject extends EncodeObject {
|
|
17
|
-
readonly typeUrl: "/mythos.wasmx.v1.MsgStoreCode";
|
|
18
|
-
readonly value: Partial<MsgStoreCode>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function isMsgStoreCodeEncodeObject(object: EncodeObject): object is MsgStoreCodeEncodeObject {
|
|
22
|
-
return (object as MsgStoreCodeEncodeObject).typeUrl === "/mythos.wasmx.v1.MsgStoreCode";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface MsgDeployCodeEncodeObject extends EncodeObject {
|
|
26
|
-
readonly typeUrl: "/mythos.wasmx.v1.MsgDeployCode";
|
|
27
|
-
readonly value: Partial<MsgDeployCode>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function isMsgDeployCodeEncodeObject(object: EncodeObject): object is MsgDeployCodeEncodeObject {
|
|
31
|
-
return (object as MsgDeployCodeEncodeObject).typeUrl === "/mythos.wasmx.v1.MsgDeployCode";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface MsgInstantiateContractEncodeObject extends EncodeObject {
|
|
35
|
-
readonly typeUrl: "/mythos.wasmx.v1.MsgInstantiateContract";
|
|
36
|
-
readonly value: Partial<MsgInstantiateContract>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function isMsgInstantiateContractEncodeObject(
|
|
40
|
-
object: EncodeObject,
|
|
41
|
-
): object is MsgInstantiateContractEncodeObject {
|
|
42
|
-
return (
|
|
43
|
-
(object as MsgInstantiateContractEncodeObject).typeUrl === "/mythos.wasmx.v1.MsgInstantiateContract"
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface MsgExecuteContractEncodeObject extends EncodeObject {
|
|
48
|
-
readonly typeUrl: "/mythos.wasmx.v1.MsgExecuteContract";
|
|
49
|
-
readonly value: Partial<MsgExecuteContract>;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function isMsgExecuteEncodeObject(object: EncodeObject): object is MsgExecuteContractEncodeObject {
|
|
53
|
-
return (object as MsgExecuteContractEncodeObject).typeUrl === "/mythos.wasmx.v1.MsgExecuteContract";
|
|
54
|
-
}
|
|
@@ -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
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
accountFromAny,
|
|
3
|
-
} from "@cosmjs/stargate";
|
|
4
|
-
import { decodePubkey } from "@cosmjs/proto-signing";
|
|
5
|
-
import { Uint64 } from "@cosmjs/math";
|
|
6
|
-
import { assert } from "@cosmjs/utils";
|
|
7
|
-
import { mythos } from "@ark-us/wasmxjs"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Basic implementation of AccountParser. This is supposed to support the most relevant
|
|
11
|
-
* common Cosmos SDK account types. If you need support for exotic account types,
|
|
12
|
-
* you'll need to write your own account decoder.
|
|
13
|
-
*/
|
|
14
|
-
export function accountFromAnyWasmx(input: any) {
|
|
15
|
-
const { typeUrl, value } = input;
|
|
16
|
-
switch (typeUrl) {
|
|
17
|
-
// auth
|
|
18
|
-
case "/mythos.cosmosmod.v1.BaseAccount":
|
|
19
|
-
return accountFromBaseAccount(mythos.cosmosmod.v1.BaseAccount.decode(value));
|
|
20
|
-
case "/mythos.cosmosmod.v1.ModuleAccount": {
|
|
21
|
-
const baseAccount = mythos.cosmosmod.v1.ModuleAccount.decode(value).baseAccount;
|
|
22
|
-
assert(baseAccount);
|
|
23
|
-
return accountFromBaseAccount(baseAccount);
|
|
24
|
-
}
|
|
25
|
-
default:
|
|
26
|
-
return accountFromAny(input)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function accountFromBaseAccount(input: any) {
|
|
31
|
-
const { address, pubKey, accountNumber, sequence } = input;
|
|
32
|
-
const pubkey = pubKey ? decodePubkey(pubKey) : null;
|
|
33
|
-
return {
|
|
34
|
-
address: address,
|
|
35
|
-
pubkey: pubkey,
|
|
36
|
-
accountNumber: uint64FromProto(accountNumber).toNumber(),
|
|
37
|
-
sequence: uint64FromProto(sequence).toNumber(),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function uint64FromProto(input: any) {
|
|
42
|
-
return Uint64.fromString(input.toString());
|
|
43
|
-
}
|