forked from DA0-DA0/dao-dao-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PolytoneProxy.ts
95 lines (88 loc) · 2.16 KB
/
PolytoneProxy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* This file was automatically generated by @cosmwasm/[email protected].
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
import { Coin, StdFee } from '@cosmjs/amino'
import {
CosmWasmClient,
ExecuteResult,
SigningCosmWasmClient,
} from '@cosmjs/cosmwasm-stargate'
import { Addr, CosmosMsgForEmpty } from '@dao-dao/types/contracts/common'
export interface PolytoneProxyReadOnlyInterface {
contractAddress: string
instantiator: () => Promise<Addr>
}
export class PolytoneProxyQueryClient
implements PolytoneProxyReadOnlyInterface
{
client: CosmWasmClient
contractAddress: string
constructor(client: CosmWasmClient, contractAddress: string) {
this.client = client
this.contractAddress = contractAddress
this.instantiator = this.instantiator.bind(this)
}
instantiator = async (): Promise<Addr> => {
return this.client.queryContractSmart(this.contractAddress, {
instantiator: {},
})
}
}
export interface PolytoneProxyInterface extends PolytoneProxyReadOnlyInterface {
contractAddress: string
sender: string
proxy: (
{
msgs,
}: {
msgs: CosmosMsgForEmpty[]
},
fee?: number | StdFee | 'auto',
memo?: string,
_funds?: Coin[]
) => Promise<ExecuteResult>
}
export class PolytoneProxyClient
extends PolytoneProxyQueryClient
implements PolytoneProxyInterface
{
client: SigningCosmWasmClient
sender: string
contractAddress: string
constructor(
client: SigningCosmWasmClient,
sender: string,
contractAddress: string
) {
super(client, contractAddress)
this.client = client
this.sender = sender
this.contractAddress = contractAddress
this.proxy = this.proxy.bind(this)
}
proxy = async (
{
msgs,
}: {
msgs: CosmosMsgForEmpty[]
},
fee: number | StdFee | 'auto' = 'auto',
memo?: string,
_funds?: Coin[]
): Promise<ExecuteResult> => {
return await this.client.execute(
this.sender,
this.contractAddress,
{
proxy: {
msgs,
},
},
fee,
memo,
_funds
)
}
}