Skip to content

Commit 6a80de8

Browse files
findolororkunkl
authored andcommitted
Lint code
1 parent 4cac217 commit 6a80de8

File tree

1 file changed

+55
-39
lines changed

1 file changed

+55
-39
lines changed

contracts/cw4-group/helpers.ts

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,31 @@ import { calculateFee } from "@cosmjs/stargate"
3636
* const instance = await contract.instantiate(addr, codeId, initMsg, 'Potato Coin!', pebblenetOptions);
3737
*
3838
* If you want to use this code inside an app, you will need several imports from https://github.com/CosmWasm/cosmjs
39-
*/
39+
*/
4040

4141
interface AdminResponse {
4242
readonly admin?: string
4343
}
4444

4545
interface MemberResponse {
46-
readonly weight?: number;
46+
readonly weight?: number
4747
}
4848

4949
interface MemberListResponse {
50-
readonly members: Member[];
50+
readonly members: Member[]
5151
}
5252

5353
interface Member {
54-
readonly addr: string;
55-
readonly weight: number;
54+
readonly addr: string
55+
readonly weight: number
5656
}
5757

5858
interface TotalWeightResponse {
59-
readonly weight: number;
59+
readonly weight: number
6060
}
6161

6262
interface HooksResponse {
63-
readonly hooks: readonly string[];
63+
readonly hooks: readonly string[]
6464
}
6565

6666
interface CW4GroupInstance {
@@ -75,7 +75,7 @@ interface CW4GroupInstance {
7575

7676
// actions
7777
updateAdmin: (txSigner: string, admin?: string) => Promise<string>
78-
updateMembers: (txSigner: string, remove: Member[], add: Member[] ) => Promise<string>
78+
updateMembers: (txSigner: string, remove: Member[], add: Member[]) => Promise<string>
7979

8080
// will not used by end user for testing purposes
8181
_addHook: (txSigner: string, addr: string) => Promise<string>
@@ -84,59 +84,65 @@ interface CW4GroupInstance {
8484

8585
interface CW4GroupContract {
8686
upload: (txSigner: string, options: Options) => Promise<number>
87-
instantiate: (txSigner: string, codeId: number, initMsg: Record<string, unknown>, label: string, options: Options, admin?: string) => Promise<CW4GroupInstance>
87+
instantiate: (
88+
txSigner: string,
89+
codeId: number,
90+
initMsg: Record<string, unknown>,
91+
label: string,
92+
options: Options,
93+
admin?: string,
94+
) => Promise<CW4GroupInstance>
8895
use: (contractAddress: string) => CW4GroupInstance
8996
}
9097

9198
export const CW4Group = (client: SigningCosmWasmClient, options: Options): CW4GroupContract => {
9299
const use = (contractAddress: string): CW4GroupInstance => {
93-
94100
const admin = async (): Promise<AdminResponse> => {
95-
return client.queryContractSmart(contractAddress, {admin: {}});
96-
};
101+
return client.queryContractSmart(contractAddress, { admin: {} })
102+
}
97103

98104
const totalWeight = async (): Promise<TotalWeightResponse> => {
99-
return client.queryContractSmart(contractAddress, {total_weight: {}});
100-
};
105+
return client.queryContractSmart(contractAddress, { total_weight: {} })
106+
}
101107

102108
const member = async (addr: string, atHeight?: number): Promise<MemberResponse> => {
103-
return client.queryContractSmart(contractAddress, {member: {addr, at_height: atHeight}});
104-
};
109+
return client.queryContractSmart(contractAddress, { member: { addr, at_height: atHeight } })
110+
}
105111

106112
const listMembers = async (startAfter?: string, limit?: number): Promise<MemberListResponse> => {
107-
return client.queryContractSmart(contractAddress, {list_members: {start_after: startAfter, limit}});
108-
};
113+
return client.queryContractSmart(contractAddress, { list_members: { start_after: startAfter, limit } })
114+
}
109115

110116
const hooks = async (): Promise<HooksResponse> => {
111-
return client.queryContractSmart(contractAddress, {hooks: {}});
112-
};
117+
return client.queryContractSmart(contractAddress, { hooks: {} })
118+
}
113119

114120
const updateAdmin = async (txSigner: string, admin?: string): Promise<string> => {
115121
const fee = calculateFee(options.fees.exec, options.gasPrice)
116122

117-
const result = await client.execute(txSigner, contractAddress, {update_admin: {admin}}, fee);
118-
return result.transactionHash;
123+
const result = await client.execute(txSigner, contractAddress, { update_admin: { admin } }, fee)
124+
return result.transactionHash
119125
}
120126

121127
const updateMembers = async (txSigner: string, remove: Member[], add: Member[]): Promise<string> => {
122128
const fee = calculateFee(options.fees.exec, options.gasPrice)
123129

124-
const result = await client.execute(txSigner, contractAddress, {update_members: {remove, add}}, fee);
125-
return result.transactionHash;
130+
const result = await client.execute(txSigner, contractAddress, { update_members: { remove, add } }, fee)
131+
return result.transactionHash
126132
}
127133

128134
const _addHook = async (txSigner: string, addr: string): Promise<string> => {
129135
const fee = calculateFee(options.fees.exec, options.gasPrice)
130136

131-
const result = await client.execute(txSigner, contractAddress, {add_hook: {addr}}, fee);
132-
return result.transactionHash;
137+
const result = await client.execute(txSigner, contractAddress, { add_hook: { addr } }, fee)
138+
return result.transactionHash
133139
}
134140

135141
const _removeHook = async (txSigner: string, addr: string): Promise<string> => {
136142
const fee = calculateFee(options.fees.exec, options.gasPrice)
137143

138-
const result = await client.execute(txSigner, contractAddress, {remove_hook: {addr}}, fee);
139-
return result.transactionHash;
144+
const result = await client.execute(txSigner, contractAddress, { remove_hook: { addr } }, fee)
145+
return result.transactionHash
140146
}
141147

142148
return {
@@ -149,31 +155,41 @@ export const CW4Group = (client: SigningCosmWasmClient, options: Options): CW4Gr
149155
updateAdmin,
150156
updateMembers,
151157
_addHook,
152-
_removeHook
153-
};
158+
_removeHook,
159+
}
154160
}
155161

156162
const downloadWasm = async (url: string): Promise<Uint8Array> => {
157-
const r = await axios.get(url, { responseType: 'arraybuffer' })
163+
const r = await axios.get(url, { responseType: "arraybuffer" })
158164
if (r.status !== 200) {
159165
throw new Error(`Download error: ${r.status}`)
160166
}
161167
return r.data
162168
}
163169

164170
const upload = async (senderAddress: string, options: Options): Promise<number> => {
165-
const sourceUrl = "https://github.com/CosmWasm/cosmwasm-plus/releases/download/v0.9.0/cw4_group.wasm";
166-
const wasm = await downloadWasm(sourceUrl);
171+
const sourceUrl = "https://github.com/CosmWasm/cosmwasm-plus/releases/download/v0.9.0/cw4_group.wasm"
172+
const wasm = await downloadWasm(sourceUrl)
167173
const fee = calculateFee(options.fees.upload, options.gasPrice)
168-
const result = await client.upload(senderAddress, wasm, fee);
169-
return result.codeId;
174+
const result = await client.upload(senderAddress, wasm, fee)
175+
return result.codeId
170176
}
171177

172-
const instantiate = async (senderAddress: string, codeId: number, initMsg: Record<string, unknown>, label: string, options: Options, admin?: string): Promise<CW4GroupInstance> => {
178+
const instantiate = async (
179+
senderAddress: string,
180+
codeId: number,
181+
initMsg: Record<string, unknown>,
182+
label: string,
183+
options: Options,
184+
admin?: string,
185+
): Promise<CW4GroupInstance> => {
173186
const fee = calculateFee(options.fees.init, options.gasPrice)
174-
const result = await client.instantiate(senderAddress, codeId, initMsg, label, fee, { memo: `Init ${label}`, admin });
175-
return use(result.contractAddress);
187+
const result = await client.instantiate(senderAddress, codeId, initMsg, label, fee, {
188+
memo: `Init ${label}`,
189+
admin,
190+
})
191+
return use(result.contractAddress)
176192
}
177193

178-
return { upload, instantiate, use };
194+
return { upload, instantiate, use }
179195
}

0 commit comments

Comments
 (0)