wasm-ast-types 0.18.0 → 0.18.1

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.
@@ -18,6 +18,9 @@ it('execute', function () {
18
18
  });
19
19
  it('query classes', function () {
20
20
  (0, _testUtils.expectCode)((0, _client.createQueryClass)(queryCtx, 'WagerQueryClient', 'WagerReadOnlyInstance', _cwWager["default"].query));
21
+ });
22
+ it('execute classes', function () {
23
+ (0, _testUtils.expectCode)((0, _client.createExecuteClass)(executeCtx, 'WagerClient', 'WagerInstance', null, _cwWager["default"].execute));
21
24
  }); // it('execute classes array types', () => {
22
25
  // expectCode(createExecuteClass(
23
26
  // ctx,
@@ -72,6 +72,12 @@ var getTypeOrRef = function getTypeOrRef(obj) {
72
72
  var getArrayTypeFromItems = function getArrayTypeFromItems(items) {
73
73
  // passing in [{"type":"string"}]
74
74
  if (Array.isArray(items)) {
75
+ var _items$;
76
+
77
+ if (((_items$ = items[0]) === null || _items$ === void 0 ? void 0 : _items$.type) === 'array') {
78
+ return t.tsArrayType(t.tsArrayType(getArrayTypeFromItems(items[0])));
79
+ }
80
+
75
81
  return t.tsArrayType(t.tsArrayType(getTypeOrRef(items[0])));
76
82
  } // passing in {"items": [{"type":"string"}]}
77
83
 
@@ -1,5 +1,5 @@
1
1
  import wagerJson from '../../../../../__fixtures__/wager/cw-wager.json';
2
- import { createQueryClass, createTypeInterface } from '../client';
2
+ import { createQueryClass, createExecuteClass, createTypeInterface } from '../client';
3
3
  import { expectCode, makeContext } from '../../../test-utils';
4
4
  const queryCtx = makeContext(wagerJson.query);
5
5
  const executeCtx = makeContext(wagerJson.execute);
@@ -11,6 +11,9 @@ it('execute', () => {
11
11
  });
12
12
  it('query classes', () => {
13
13
  expectCode(createQueryClass(queryCtx, 'WagerQueryClient', 'WagerReadOnlyInstance', wagerJson.query));
14
+ });
15
+ it('execute classes', () => {
16
+ expectCode(createExecuteClass(executeCtx, 'WagerClient', 'WagerInstance', null, wagerJson.execute));
14
17
  }); // it('execute classes array types', () => {
15
18
  // expectCode(createExecuteClass(
16
19
  // ctx,
@@ -39,6 +39,10 @@ const getTypeOrRef = obj => {
39
39
  const getArrayTypeFromItems = items => {
40
40
  // passing in [{"type":"string"}]
41
41
  if (Array.isArray(items)) {
42
+ if (items[0]?.type === 'array') {
43
+ return t.tsArrayType(t.tsArrayType(getArrayTypeFromItems(items[0])));
44
+ }
45
+
42
46
  return t.tsArrayType(t.tsArrayType(getTypeOrRef(items[0])));
43
47
  } // passing in {"items": [{"type":"string"}]}
44
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wasm-ast-types",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "CosmWasm TypeScript AST generation",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "homepage": "https://github.com/pyramation/cosmwasm-typescript-gen/tree/master/packages/wasm-ast-types#readme",
@@ -88,5 +88,5 @@
88
88
  "case": "1.6.3",
89
89
  "deepmerge": "4.2.2"
90
90
  },
91
- "gitHead": "857ca4b9661677f7c1a72d0327fb327b0a318e33"
91
+ "gitHead": "e6daf701507cad95127613a815fc0fca1a883f8a"
92
92
  }
@@ -2,6 +2,84 @@
2
2
 
3
3
  exports[`execute 1`] = `"export type ExecuteMsg = ExecuteMsg;"`;
4
4
 
5
+ exports[`execute classes 1`] = `
6
+ "export class WagerClient implements WagerInstance {
7
+ client: SigningCosmWasmClient;
8
+ sender: string;
9
+ contractAddress: string;
10
+
11
+ constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) {
12
+ this.client = client;
13
+ this.sender = sender;
14
+ this.contractAddress = contractAddress;
15
+ this.updateConfig = this.updateConfig.bind(this);
16
+ this.setWinner = this.setWinner.bind(this);
17
+ this.wager = this.wager.bind(this);
18
+ this.cancel = this.cancel.bind(this);
19
+ }
20
+
21
+ updateConfig = async ({
22
+ params
23
+ }: {
24
+ params: ParamInfo;
25
+ }, fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, funds?: Coin[]): Promise<ExecuteResult> => {
26
+ return await this.client.execute(this.sender, this.contractAddress, {
27
+ update_config: {
28
+ params
29
+ }
30
+ }, fee, memo, funds);
31
+ };
32
+ setWinner = async ({
33
+ currentPrices,
34
+ prevPrices,
35
+ wagerKey
36
+ }: {
37
+ currentPrices: number[][];
38
+ prevPrices: number[][];
39
+ wagerKey: Addr[][][][];
40
+ }, fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, funds?: Coin[]): Promise<ExecuteResult> => {
41
+ return await this.client.execute(this.sender, this.contractAddress, {
42
+ set_winner: {
43
+ current_prices: currentPrices,
44
+ prev_prices: prevPrices,
45
+ wager_key: wagerKey
46
+ }
47
+ }, fee, memo, funds);
48
+ };
49
+ wager = async ({
50
+ againstCurrencies,
51
+ currency,
52
+ expiry,
53
+ token
54
+ }: {
55
+ againstCurrencies: Currency[];
56
+ currency: Currency;
57
+ expiry: number;
58
+ token: Addr[][];
59
+ }, fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, funds?: Coin[]): Promise<ExecuteResult> => {
60
+ return await this.client.execute(this.sender, this.contractAddress, {
61
+ wager: {
62
+ against_currencies: againstCurrencies,
63
+ currency,
64
+ expiry,
65
+ token
66
+ }
67
+ }, fee, memo, funds);
68
+ };
69
+ cancel = async ({
70
+ token
71
+ }: {
72
+ token: Addr[][];
73
+ }, fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, funds?: Coin[]): Promise<ExecuteResult> => {
74
+ return await this.client.execute(this.sender, this.contractAddress, {
75
+ cancel: {
76
+ token
77
+ }
78
+ }, fee, memo, funds);
79
+ };
80
+ }"
81
+ `;
82
+
5
83
  exports[`query 1`] = `"export type QueryMsg = QueryMsg;"`;
6
84
 
7
85
  exports[`query classes 1`] = `
@@ -33,6 +33,16 @@ it('query classes', () => {
33
33
  ))
34
34
  });
35
35
 
36
+ it('execute classes', () => {
37
+ expectCode(createExecuteClass(
38
+ executeCtx,
39
+ 'WagerClient',
40
+ 'WagerInstance',
41
+ null,
42
+ wagerJson.execute
43
+ ))
44
+ });
45
+
36
46
  // it('execute classes array types', () => {
37
47
  // expectCode(createExecuteClass(
38
48
  // ctx,
@@ -48,6 +48,15 @@ const getTypeOrRef = (obj) => {
48
48
  const getArrayTypeFromItems = (items) => {
49
49
  // passing in [{"type":"string"}]
50
50
  if (Array.isArray(items)) {
51
+ if (items[0]?.type === 'array') {
52
+ return t.tsArrayType(
53
+ t.tsArrayType(
54
+ getArrayTypeFromItems(
55
+ items[0]
56
+ )
57
+ )
58
+ );
59
+ }
51
60
  return t.tsArrayType(
52
61
  t.tsArrayType(
53
62
  getTypeOrRef(items[0])