forked from SO4-Markets/contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
198 lines (174 loc) · 11.8 KB
/
Copy pathindex.ts
File metadata and controls
198 lines (174 loc) · 11.8 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import { Buffer } from "buffer";
import { Address } from "@stellar/stellar-sdk";
import {
AssembledTransaction,
Client as ContractClient,
ClientOptions as ContractClientOptions,
MethodOptions,
Result,
Spec as ContractSpec,
} from "@stellar/stellar-sdk/contract";
import type {
u32,
i32,
u64,
i64,
u128,
i128,
u256,
i256,
Option,
Timepoint,
Duration,
} from "@stellar/stellar-sdk/contract";
export * from "@stellar/stellar-sdk";
export * as contract from "@stellar/stellar-sdk/contract";
export * as rpc from "@stellar/stellar-sdk/rpc";
if (typeof window !== "undefined") {
//@ts-ignore Buffer exists
window.Buffer = window.Buffer || Buffer;
}
export const Errors = {
1: {message:"AlreadyInitialized"},
2: {message:"NotInitialized"},
3: {message:"Unauthorized"},
4: {message:"InsufficientBalance"},
5: {message:"InsufficientAllowance"},
6: {message:"NegativeAmount"},
7: {message:"AllowanceExpired"},
8: {message:"Paused"}
}
export interface Client {
/**
* Construct and simulate a burn transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
burn: ({from, amount}: {from: string, amount: i128}, options?: MethodOptions) => Promise<AssembledTransaction<null>>
/**
* Construct and simulate a mint transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
mint: ({caller, account, amount}: {caller: string, account: string, amount: i128}, options?: MethodOptions) => Promise<AssembledTransaction<null>>
/**
* Construct and simulate a name transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
name: (options?: MethodOptions) => Promise<AssembledTransaction<string>>
/**
* Construct and simulate a owner transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
owner: (options?: MethodOptions) => Promise<AssembledTransaction<string>>
/**
* Construct and simulate a pause transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
pause: ({caller}: {caller: string}, options?: MethodOptions) => Promise<AssembledTransaction<null>>
/**
* Construct and simulate a paused transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
paused: (options?: MethodOptions) => Promise<AssembledTransaction<boolean>>
/**
* Construct and simulate a symbol transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
symbol: (options?: MethodOptions) => Promise<AssembledTransaction<string>>
/**
* Construct and simulate a approve transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
approve: ({from, spender, amount, expiration_ledger}: {from: string, spender: string, amount: i128, expiration_ledger: u32}, options?: MethodOptions) => Promise<AssembledTransaction<null>>
/**
* Construct and simulate a balance transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
balance: ({id}: {id: string}, options?: MethodOptions) => Promise<AssembledTransaction<i128>>
/**
* Construct and simulate a unpause transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
unpause: ({caller}: {caller: string}, options?: MethodOptions) => Promise<AssembledTransaction<null>>
/**
* Construct and simulate a decimals transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
decimals: (options?: MethodOptions) => Promise<AssembledTransaction<u32>>
/**
* Construct and simulate a transfer transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
transfer: ({from, to, amount}: {from: string, to: string, amount: i128}, options?: MethodOptions) => Promise<AssembledTransaction<null>>
/**
* Construct and simulate a allowance transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
allowance: ({from, spender}: {from: string, spender: string}, options?: MethodOptions) => Promise<AssembledTransaction<i128>>
/**
* Construct and simulate a burn_from transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
burn_from: ({spender, from, amount}: {spender: string, from: string, amount: i128}, options?: MethodOptions) => Promise<AssembledTransaction<null>>
/**
* Construct and simulate a initialize transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
initialize: ({owner, decimal, name, symbol}: {owner: string, decimal: u32, name: string, symbol: string}, options?: MethodOptions) => Promise<AssembledTransaction<null>>
/**
* Construct and simulate a total_supply transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
total_supply: (options?: MethodOptions) => Promise<AssembledTransaction<i128>>
/**
* Construct and simulate a transfer_from transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
transfer_from: ({spender, from, to, amount}: {spender: string, from: string, to: string, amount: i128}, options?: MethodOptions) => Promise<AssembledTransaction<null>>
/**
* Construct and simulate a transfer_owner transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
*/
transfer_owner: ({caller, new_owner}: {caller: string, new_owner: string}, options?: MethodOptions) => Promise<AssembledTransaction<null>>
}
export class Client extends ContractClient {
static async deploy<T = Client>(
/** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
options: MethodOptions &
Omit<ContractClientOptions, "contractId"> & {
/** The hash of the Wasm blob, which must already be installed on-chain. */
wasmHash: Buffer | string;
/** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
salt?: Buffer | Uint8Array;
/** The format used to decode `wasmHash`, if it's provided as a string. */
format?: "hex" | "base64";
}
): Promise<AssembledTransaction<T>> {
return ContractClient.deploy(null, options)
}
constructor(public readonly options: ContractClientOptions) {
super(
new ContractSpec([ "AAAABAAAAAAAAAAAAAAABUVycm9yAAAAAAAACAAAAAAAAAASQWxyZWFkeUluaXRpYWxpemVkAAAAAAABAAAAAAAAAA5Ob3RJbml0aWFsaXplZAAAAAAAAgAAAAAAAAAMVW5hdXRob3JpemVkAAAAAwAAAAAAAAATSW5zdWZmaWNpZW50QmFsYW5jZQAAAAAEAAAAAAAAABVJbnN1ZmZpY2llbnRBbGxvd2FuY2UAAAAAAAAFAAAAAAAAAA5OZWdhdGl2ZUFtb3VudAAAAAAABgAAAAAAAAAQQWxsb3dhbmNlRXhwaXJlZAAAAAcAAAAAAAAABlBhdXNlZAAAAAAACA==",
"AAAAAAAAAAAAAAAEYnVybgAAAAIAAAAAAAAABGZyb20AAAATAAAA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AALAAAAAA==",
"AAAAAAAAAAAAAAAKaW5pdGlhbGl6ZQAAAAAABAAAAAAAAAAFb3duZXIAAAAAAAATAAAAAAAAAAdkZWNpbWFsAAAAAAQAAAAAAAAABG5hbWUAAAAQAAAAAAAAAAZzeW1ib2wAAAAAABAAAAAA",
"AAAAAAAAAAAAAAAMdG90YWxfc3VwcGx5AAAAAAAAAAEAAAAL",
"AAAAAAAAAAAAAAANdHJhbnNmZXJfZnJvbQAAAAAAAAQAAAAAAAAAB3NwZW5kZXIAAAAAEwAAAAAAAAAEZnJvbQAAABMAAAAAAAAAAnRvAAAAAAATAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAA",
"AAAAAAAAAAAAAAAOdHJhbnNmZXJfb3duZXIAAAAAAAIAAAAAAAAABmNhbGxlcgAAAAAAEwAAAAAAAAAJbmV3X293bmVyAAAAAAAAEwAAAAA=" ]),
options
)
}
public readonly fromJSON = {
burn: this.txFromJSON<null>,
mint: this.txFromJSON<null>,
name: this.txFromJSON<string>,
owner: this.txFromJSON<string>,
pause: this.txFromJSON<null>,
paused: this.txFromJSON<boolean>,
symbol: this.txFromJSON<string>,
approve: this.txFromJSON<null>,
balance: this.txFromJSON<i128>,
unpause: this.txFromJSON<null>,
decimals: this.txFromJSON<u32>,
transfer: this.txFromJSON<null>,
allowance: this.txFromJSON<i128>,
burn_from: this.txFromJSON<null>,
initialize: this.txFromJSON<null>,
total_supply: this.txFromJSON<i128>,
transfer_from: this.txFromJSON<null>,
transfer_owner: this.txFromJSON<null>
}
}