@alephium/powfi-sdk 0.0.1-rc.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.
- package/README.md +4 -0
- package/clmm/artifacts/BitmapWord.ral.json +125 -0
- package/clmm/artifacts/BitmapWordDeployer.ral.json +31 -0
- package/clmm/artifacts/CreateConfig.ral.json +37 -0
- package/clmm/artifacts/CreateLiquidPool.ral.json +55 -0
- package/clmm/artifacts/DexAccount.ral.json +110 -0
- package/clmm/artifacts/LiquidityAmountsTest.ral.json +161 -0
- package/clmm/artifacts/LiquidityManagmentTest.ral.json +384 -0
- package/clmm/artifacts/Pool.ral.json +1530 -0
- package/clmm/artifacts/PoolConfig.ral.json +31 -0
- package/clmm/artifacts/PoolFactory.ral.json +300 -0
- package/clmm/artifacts/PoolRouterDemo.ral.json +49 -0
- package/clmm/artifacts/PoolUser.ral.json +89 -0
- package/clmm/artifacts/Position.ral.json +183 -0
- package/clmm/artifacts/PositionManager.ral.json +416 -0
- package/clmm/artifacts/SwapWithoutAccount.ral.json +46 -0
- package/clmm/artifacts/TestToken.ral.json +68 -0
- package/clmm/artifacts/Tick.ral.json +161 -0
- package/clmm/artifacts/TickBitmapTest.ral.json +220 -0
- package/clmm/artifacts/constants.ral.json +81 -0
- package/clmm/artifacts/structs.ral.json +335 -0
- package/clmm/artifacts/ts/BitmapWord.ts +337 -0
- package/clmm/artifacts/ts/BitmapWordDeployer.ts +164 -0
- package/clmm/artifacts/ts/DexAccount.ts +330 -0
- package/clmm/artifacts/ts/LiquidityAmountsTest.ts +464 -0
- package/clmm/artifacts/ts/LiquidityManagmentTest.ts +859 -0
- package/clmm/artifacts/ts/Pool.ts +2535 -0
- package/clmm/artifacts/ts/PoolConfig.ts +179 -0
- package/clmm/artifacts/ts/PoolFactory.ts +640 -0
- package/clmm/artifacts/ts/PoolUser.ts +237 -0
- package/clmm/artifacts/ts/Position.ts +440 -0
- package/clmm/artifacts/ts/PositionManager.ts +929 -0
- package/clmm/artifacts/ts/TestToken.ts +277 -0
- package/clmm/artifacts/ts/Tick.ts +351 -0
- package/clmm/artifacts/ts/TickBitmapTest.ts +512 -0
- package/clmm/artifacts/ts/constants.ts +17 -0
- package/clmm/artifacts/ts/contracts.ts +26 -0
- package/clmm/artifacts/ts/deployments.ts +160 -0
- package/clmm/artifacts/ts/index.ts +20 -0
- package/clmm/artifacts/ts/scripts.ts +76 -0
- package/clmm/artifacts/ts/types.ts +105 -0
- package/clmm/deployments/.deployments.devnet.json +350 -0
- package/clmm/deployments/.deployments.testnet.json +350 -0
- package/cpmm/artifacts/dex/DexAccount.ral.json +110 -0
- package/cpmm/artifacts/dex/Router.ral.json +361 -0
- package/cpmm/artifacts/dex/TokenPair.ral.json +512 -0
- package/cpmm/artifacts/dex/TokenPairFactory.ral.json +297 -0
- package/cpmm/artifacts/examples/ExampleOracleSimple.ral.json +192 -0
- package/cpmm/artifacts/examples/FeeCollectorFactoryImpl.ral.json +185 -0
- package/cpmm/artifacts/examples/FeeCollectorPerTokenPairImpl.ral.json +216 -0
- package/cpmm/artifacts/examples/FullMathTest.ral.json +123 -0
- package/cpmm/artifacts/scripts/AddLiquidity.ral.json +46 -0
- package/cpmm/artifacts/scripts/Burn.ral.json +31 -0
- package/cpmm/artifacts/scripts/CollectFee.ral.json +25 -0
- package/cpmm/artifacts/scripts/CreatePair.ral.json +37 -0
- package/cpmm/artifacts/scripts/CreatePairAndAddLiquidity.ral.json +43 -0
- package/cpmm/artifacts/scripts/EnableFeeCollector.ral.json +28 -0
- package/cpmm/artifacts/scripts/Mint.ral.json +34 -0
- package/cpmm/artifacts/scripts/RemoveLiquidity.ral.json +43 -0
- package/cpmm/artifacts/scripts/SetFeeCollectorFactory.ral.json +28 -0
- package/cpmm/artifacts/scripts/Swap.ral.json +46 -0
- package/cpmm/artifacts/scripts/SwapMaxIn.ral.json +46 -0
- package/cpmm/artifacts/scripts/SwapMinOut.ral.json +46 -0
- package/cpmm/artifacts/test/GetToken.ral.json +31 -0
- package/cpmm/artifacts/test/MathTest.ral.json +49 -0
- package/cpmm/artifacts/test/TestToken.ral.json +87 -0
- package/cpmm/artifacts/ts/DexAccount.ts +329 -0
- package/cpmm/artifacts/ts/ExampleOracleSimple.ts +383 -0
- package/cpmm/artifacts/ts/FeeCollectorFactoryImpl.ts +227 -0
- package/cpmm/artifacts/ts/FeeCollectorPerTokenPairImpl.ts +327 -0
- package/cpmm/artifacts/ts/FullMathTest.ts +251 -0
- package/cpmm/artifacts/ts/MathTest.ts +183 -0
- package/cpmm/artifacts/ts/Router.ts +554 -0
- package/cpmm/artifacts/ts/TestToken.ts +312 -0
- package/cpmm/artifacts/ts/TokenPair.ts +947 -0
- package/cpmm/artifacts/ts/TokenPairFactory.ts +501 -0
- package/cpmm/artifacts/ts/contracts.ts +26 -0
- package/cpmm/artifacts/ts/deployments.ts +109 -0
- package/cpmm/artifacts/ts/index.ts +16 -0
- package/cpmm/artifacts/ts/scripts.ts +142 -0
- package/cpmm/deployments/.deployments.devnet.json +77 -0
- package/cpmm/deployments/.deployments.testnet.json +79 -0
- package/lib/index.d.mts +8800 -0
- package/lib/index.d.ts +8800 -0
- package/lib/index.js +21769 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +22118 -0
- package/lib/index.mjs.map +1 -0
- package/package.json +80 -0
- package/src/clmm/clmm.ts +607 -0
- package/src/clmm/constants.ts +7 -0
- package/src/clmm/index.ts +6 -0
- package/src/clmm/liquidity.ts +163 -0
- package/src/clmm/pool.ts +154 -0
- package/src/clmm/tick.ts +335 -0
- package/src/clmm/types.ts +155 -0
- package/src/common/constants.ts +1 -0
- package/src/common/error.ts +46 -0
- package/src/common/index.ts +7 -0
- package/src/common/logger.ts +82 -0
- package/src/common/math.ts +88 -0
- package/src/common/numeric.ts +64 -0
- package/src/common/types.ts +49 -0
- package/src/common/utils.ts +3 -0
- package/src/cpmm/constants.ts +2 -0
- package/src/cpmm/cpmm.ts +631 -0
- package/src/cpmm/index.ts +3 -0
- package/src/cpmm/types.ts +113 -0
- package/src/index.ts +25 -0
- package/src/moduleBase.ts +64 -0
- package/src/staking/index.ts +4 -0
- package/src/staking/settings.ts +38 -0
- package/src/staking/staking.ts +277 -0
- package/src/staking/types.ts +15 -0
- package/src/staking/utils.ts +25 -0
- package/src/token/index.ts +1 -0
- package/src/token/token.ts +163 -0
- package/src/zeta.ts +105 -0
- package/staking/artifacts/AlphStakeAndLock.ral.json +31 -0
- package/staking/artifacts/AlphUnstakeVault.ral.json +151 -0
- package/staking/artifacts/XAlphStakeVault.ral.json +559 -0
- package/staking/artifacts/XAlphToken.ral.json +404 -0
- package/staking/artifacts/XAlphUnlockAndStartUnstake.ral.json +31 -0
- package/staking/artifacts/examples/GovernanceDemo.ral.json +282 -0
- package/staking/artifacts/examples/RewardSharingVault.ral.json +253 -0
- package/staking/artifacts/structs.ral.json +47 -0
- package/staking/artifacts/ts/AlphUnstakeVault.ts +354 -0
- package/staking/artifacts/ts/FullMathTest.ts +175 -0
- package/staking/artifacts/ts/GovernanceDemo.ts +726 -0
- package/staking/artifacts/ts/RewardSharingVault.ts +559 -0
- package/staking/artifacts/ts/TestDynamicArrayByteVec32.ts +431 -0
- package/staking/artifacts/ts/TestDynamicSortedArrayForU256.ts +516 -0
- package/staking/artifacts/ts/TestMerkleProof.ts +343 -0
- package/staking/artifacts/ts/XAlphStakeVault.ts +1120 -0
- package/staking/artifacts/ts/XAlphToken.ts +835 -0
- package/staking/artifacts/ts/contracts.ts +26 -0
- package/staking/artifacts/ts/deployments.ts +109 -0
- package/staking/artifacts/ts/index.ts +15 -0
- package/staking/artifacts/ts/scripts.ts +35 -0
- package/staking/artifacts/ts/types.ts +19 -0
- package/staking/artifacts/utils/FullMathTest.ral.json +57 -0
- package/staking/artifacts/utils/TestDynamicArrayByteVec32.ral.json +165 -0
- package/staking/artifacts/utils/TestDynamicSortedArrayForU256.ral.json +189 -0
- package/staking/artifacts/utils/TestMerkleProof.ral.json +134 -0
- package/staking/deployments/.deployments.devnet.json +77 -0
- package/staking/deployments/.deployments.testnet.json +78 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/* Autogenerated file. Do not edit manually. */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Address,
|
|
7
|
+
Contract,
|
|
8
|
+
ContractState,
|
|
9
|
+
TestContractResult,
|
|
10
|
+
HexString,
|
|
11
|
+
ContractFactory,
|
|
12
|
+
EventSubscribeOptions,
|
|
13
|
+
EventSubscription,
|
|
14
|
+
CallContractParams,
|
|
15
|
+
CallContractResult,
|
|
16
|
+
TestContractParams,
|
|
17
|
+
ContractEvent,
|
|
18
|
+
subscribeContractEvent,
|
|
19
|
+
subscribeContractEvents,
|
|
20
|
+
testMethod,
|
|
21
|
+
callMethod,
|
|
22
|
+
multicallMethods,
|
|
23
|
+
fetchContractState,
|
|
24
|
+
Asset,
|
|
25
|
+
ContractInstance,
|
|
26
|
+
getContractEventsCurrentCount,
|
|
27
|
+
TestContractParamsWithoutMaps,
|
|
28
|
+
TestContractResultWithoutMaps,
|
|
29
|
+
SignExecuteContractMethodParams,
|
|
30
|
+
SignExecuteScriptTxResult,
|
|
31
|
+
signExecuteMethod,
|
|
32
|
+
addStdIdToFields,
|
|
33
|
+
encodeContractFields,
|
|
34
|
+
Narrow,
|
|
35
|
+
} from "@alephium/web3";
|
|
36
|
+
import { default as BitmapWordContractJson } from "../BitmapWord.ral.json";
|
|
37
|
+
import { getContractByCodeHash, registerContract } from "./contracts";
|
|
38
|
+
import * as types from "./types";
|
|
39
|
+
|
|
40
|
+
// Custom types for the contract
|
|
41
|
+
export namespace BitmapWordTypes {
|
|
42
|
+
export type Fields = {
|
|
43
|
+
parent: Address;
|
|
44
|
+
value: bigint;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type State = ContractState<Fields>;
|
|
48
|
+
|
|
49
|
+
export interface CallMethodTable {
|
|
50
|
+
mostSignificantBit: {
|
|
51
|
+
params: CallContractParams<{ x: bigint }>;
|
|
52
|
+
result: CallContractResult<bigint>;
|
|
53
|
+
};
|
|
54
|
+
leastSignificantBit: {
|
|
55
|
+
params: CallContractParams<{ x: bigint }>;
|
|
56
|
+
result: CallContractResult<bigint>;
|
|
57
|
+
};
|
|
58
|
+
flip: {
|
|
59
|
+
params: CallContractParams<{ tick: bigint }>;
|
|
60
|
+
result: CallContractResult<null>;
|
|
61
|
+
};
|
|
62
|
+
getNext: {
|
|
63
|
+
params: CallContractParams<{
|
|
64
|
+
compressed: bigint;
|
|
65
|
+
zeroForOne: boolean;
|
|
66
|
+
tickSpacing: bigint;
|
|
67
|
+
}>;
|
|
68
|
+
result: CallContractResult<[bigint, boolean]>;
|
|
69
|
+
};
|
|
70
|
+
getBitPos: {
|
|
71
|
+
params: CallContractParams<{ tick: bigint }>;
|
|
72
|
+
result: CallContractResult<bigint>;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export type CallMethodParams<T extends keyof CallMethodTable> =
|
|
76
|
+
CallMethodTable[T]["params"];
|
|
77
|
+
export type CallMethodResult<T extends keyof CallMethodTable> =
|
|
78
|
+
CallMethodTable[T]["result"];
|
|
79
|
+
export type MultiCallParams = Partial<{
|
|
80
|
+
[Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
|
|
81
|
+
}>;
|
|
82
|
+
export type MultiCallResults<T extends MultiCallParams> = {
|
|
83
|
+
[MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
|
|
84
|
+
? CallMethodTable[MaybeName]["result"]
|
|
85
|
+
: undefined;
|
|
86
|
+
};
|
|
87
|
+
export type MulticallReturnType<Callss extends MultiCallParams[]> = {
|
|
88
|
+
[index in keyof Callss]: MultiCallResults<Callss[index]>;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export interface SignExecuteMethodTable {
|
|
92
|
+
mostSignificantBit: {
|
|
93
|
+
params: SignExecuteContractMethodParams<{ x: bigint }>;
|
|
94
|
+
result: SignExecuteScriptTxResult;
|
|
95
|
+
};
|
|
96
|
+
leastSignificantBit: {
|
|
97
|
+
params: SignExecuteContractMethodParams<{ x: bigint }>;
|
|
98
|
+
result: SignExecuteScriptTxResult;
|
|
99
|
+
};
|
|
100
|
+
flip: {
|
|
101
|
+
params: SignExecuteContractMethodParams<{ tick: bigint }>;
|
|
102
|
+
result: SignExecuteScriptTxResult;
|
|
103
|
+
};
|
|
104
|
+
getNext: {
|
|
105
|
+
params: SignExecuteContractMethodParams<{
|
|
106
|
+
compressed: bigint;
|
|
107
|
+
zeroForOne: boolean;
|
|
108
|
+
tickSpacing: bigint;
|
|
109
|
+
}>;
|
|
110
|
+
result: SignExecuteScriptTxResult;
|
|
111
|
+
};
|
|
112
|
+
getBitPos: {
|
|
113
|
+
params: SignExecuteContractMethodParams<{ tick: bigint }>;
|
|
114
|
+
result: SignExecuteScriptTxResult;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
|
|
118
|
+
SignExecuteMethodTable[T]["params"];
|
|
119
|
+
export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
|
|
120
|
+
SignExecuteMethodTable[T]["result"];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
class Factory extends ContractFactory<
|
|
124
|
+
BitmapWordInstance,
|
|
125
|
+
BitmapWordTypes.Fields
|
|
126
|
+
> {
|
|
127
|
+
encodeFields(fields: BitmapWordTypes.Fields) {
|
|
128
|
+
return encodeContractFields(
|
|
129
|
+
addStdIdToFields(this.contract, fields),
|
|
130
|
+
this.contract.fieldsSig,
|
|
131
|
+
types.AllStructs
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
consts = {
|
|
136
|
+
BitMathError: {
|
|
137
|
+
NoMostSignificantBit: BigInt("150"),
|
|
138
|
+
NoLeastSignificantBit: BigInt("151"),
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
at(address: string): BitmapWordInstance {
|
|
143
|
+
return new BitmapWordInstance(address);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
tests = {
|
|
147
|
+
mostSignificantBit: async (
|
|
148
|
+
params: TestContractParamsWithoutMaps<
|
|
149
|
+
BitmapWordTypes.Fields,
|
|
150
|
+
{ x: bigint }
|
|
151
|
+
>
|
|
152
|
+
): Promise<TestContractResultWithoutMaps<bigint>> => {
|
|
153
|
+
return testMethod(
|
|
154
|
+
this,
|
|
155
|
+
"mostSignificantBit",
|
|
156
|
+
params,
|
|
157
|
+
getContractByCodeHash
|
|
158
|
+
);
|
|
159
|
+
},
|
|
160
|
+
leastSignificantBit: async (
|
|
161
|
+
params: TestContractParamsWithoutMaps<
|
|
162
|
+
BitmapWordTypes.Fields,
|
|
163
|
+
{ x: bigint }
|
|
164
|
+
>
|
|
165
|
+
): Promise<TestContractResultWithoutMaps<bigint>> => {
|
|
166
|
+
return testMethod(
|
|
167
|
+
this,
|
|
168
|
+
"leastSignificantBit",
|
|
169
|
+
params,
|
|
170
|
+
getContractByCodeHash
|
|
171
|
+
);
|
|
172
|
+
},
|
|
173
|
+
flip: async (
|
|
174
|
+
params: TestContractParamsWithoutMaps<
|
|
175
|
+
BitmapWordTypes.Fields,
|
|
176
|
+
{ tick: bigint }
|
|
177
|
+
>
|
|
178
|
+
): Promise<TestContractResultWithoutMaps<null>> => {
|
|
179
|
+
return testMethod(this, "flip", params, getContractByCodeHash);
|
|
180
|
+
},
|
|
181
|
+
getNext: async (
|
|
182
|
+
params: TestContractParamsWithoutMaps<
|
|
183
|
+
BitmapWordTypes.Fields,
|
|
184
|
+
{ compressed: bigint; zeroForOne: boolean; tickSpacing: bigint }
|
|
185
|
+
>
|
|
186
|
+
): Promise<TestContractResultWithoutMaps<[bigint, boolean]>> => {
|
|
187
|
+
return testMethod(this, "getNext", params, getContractByCodeHash);
|
|
188
|
+
},
|
|
189
|
+
getBitPos: async (
|
|
190
|
+
params: TestContractParamsWithoutMaps<
|
|
191
|
+
BitmapWordTypes.Fields,
|
|
192
|
+
{ tick: bigint }
|
|
193
|
+
>
|
|
194
|
+
): Promise<TestContractResultWithoutMaps<bigint>> => {
|
|
195
|
+
return testMethod(this, "getBitPos", params, getContractByCodeHash);
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
stateForTest(
|
|
200
|
+
initFields: BitmapWordTypes.Fields,
|
|
201
|
+
asset?: Asset,
|
|
202
|
+
address?: string
|
|
203
|
+
) {
|
|
204
|
+
return this.stateForTest_(initFields, asset, address, undefined);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Use this object to test and deploy the contract
|
|
209
|
+
export const BitmapWord = new Factory(
|
|
210
|
+
Contract.fromJson(
|
|
211
|
+
BitmapWordContractJson,
|
|
212
|
+
"",
|
|
213
|
+
"69fd344eb51899a9bdc30ae94beeb2dcfeb2fc312d39116ebe9d208a55293edd",
|
|
214
|
+
types.AllStructs
|
|
215
|
+
)
|
|
216
|
+
);
|
|
217
|
+
registerContract(BitmapWord);
|
|
218
|
+
|
|
219
|
+
// Use this class to interact with the blockchain
|
|
220
|
+
export class BitmapWordInstance extends ContractInstance {
|
|
221
|
+
constructor(address: Address) {
|
|
222
|
+
super(address);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async fetchState(): Promise<BitmapWordTypes.State> {
|
|
226
|
+
return fetchContractState(BitmapWord, this);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
view = {
|
|
230
|
+
mostSignificantBit: async (
|
|
231
|
+
params: BitmapWordTypes.CallMethodParams<"mostSignificantBit">
|
|
232
|
+
): Promise<BitmapWordTypes.CallMethodResult<"mostSignificantBit">> => {
|
|
233
|
+
return callMethod(
|
|
234
|
+
BitmapWord,
|
|
235
|
+
this,
|
|
236
|
+
"mostSignificantBit",
|
|
237
|
+
params,
|
|
238
|
+
getContractByCodeHash
|
|
239
|
+
);
|
|
240
|
+
},
|
|
241
|
+
leastSignificantBit: async (
|
|
242
|
+
params: BitmapWordTypes.CallMethodParams<"leastSignificantBit">
|
|
243
|
+
): Promise<BitmapWordTypes.CallMethodResult<"leastSignificantBit">> => {
|
|
244
|
+
return callMethod(
|
|
245
|
+
BitmapWord,
|
|
246
|
+
this,
|
|
247
|
+
"leastSignificantBit",
|
|
248
|
+
params,
|
|
249
|
+
getContractByCodeHash
|
|
250
|
+
);
|
|
251
|
+
},
|
|
252
|
+
flip: async (
|
|
253
|
+
params: BitmapWordTypes.CallMethodParams<"flip">
|
|
254
|
+
): Promise<BitmapWordTypes.CallMethodResult<"flip">> => {
|
|
255
|
+
return callMethod(
|
|
256
|
+
BitmapWord,
|
|
257
|
+
this,
|
|
258
|
+
"flip",
|
|
259
|
+
params,
|
|
260
|
+
getContractByCodeHash
|
|
261
|
+
);
|
|
262
|
+
},
|
|
263
|
+
getNext: async (
|
|
264
|
+
params: BitmapWordTypes.CallMethodParams<"getNext">
|
|
265
|
+
): Promise<BitmapWordTypes.CallMethodResult<"getNext">> => {
|
|
266
|
+
return callMethod(
|
|
267
|
+
BitmapWord,
|
|
268
|
+
this,
|
|
269
|
+
"getNext",
|
|
270
|
+
params,
|
|
271
|
+
getContractByCodeHash
|
|
272
|
+
);
|
|
273
|
+
},
|
|
274
|
+
getBitPos: async (
|
|
275
|
+
params: BitmapWordTypes.CallMethodParams<"getBitPos">
|
|
276
|
+
): Promise<BitmapWordTypes.CallMethodResult<"getBitPos">> => {
|
|
277
|
+
return callMethod(
|
|
278
|
+
BitmapWord,
|
|
279
|
+
this,
|
|
280
|
+
"getBitPos",
|
|
281
|
+
params,
|
|
282
|
+
getContractByCodeHash
|
|
283
|
+
);
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
transact = {
|
|
288
|
+
mostSignificantBit: async (
|
|
289
|
+
params: BitmapWordTypes.SignExecuteMethodParams<"mostSignificantBit">
|
|
290
|
+
): Promise<
|
|
291
|
+
BitmapWordTypes.SignExecuteMethodResult<"mostSignificantBit">
|
|
292
|
+
> => {
|
|
293
|
+
return signExecuteMethod(BitmapWord, this, "mostSignificantBit", params);
|
|
294
|
+
},
|
|
295
|
+
leastSignificantBit: async (
|
|
296
|
+
params: BitmapWordTypes.SignExecuteMethodParams<"leastSignificantBit">
|
|
297
|
+
): Promise<
|
|
298
|
+
BitmapWordTypes.SignExecuteMethodResult<"leastSignificantBit">
|
|
299
|
+
> => {
|
|
300
|
+
return signExecuteMethod(BitmapWord, this, "leastSignificantBit", params);
|
|
301
|
+
},
|
|
302
|
+
flip: async (
|
|
303
|
+
params: BitmapWordTypes.SignExecuteMethodParams<"flip">
|
|
304
|
+
): Promise<BitmapWordTypes.SignExecuteMethodResult<"flip">> => {
|
|
305
|
+
return signExecuteMethod(BitmapWord, this, "flip", params);
|
|
306
|
+
},
|
|
307
|
+
getNext: async (
|
|
308
|
+
params: BitmapWordTypes.SignExecuteMethodParams<"getNext">
|
|
309
|
+
): Promise<BitmapWordTypes.SignExecuteMethodResult<"getNext">> => {
|
|
310
|
+
return signExecuteMethod(BitmapWord, this, "getNext", params);
|
|
311
|
+
},
|
|
312
|
+
getBitPos: async (
|
|
313
|
+
params: BitmapWordTypes.SignExecuteMethodParams<"getBitPos">
|
|
314
|
+
): Promise<BitmapWordTypes.SignExecuteMethodResult<"getBitPos">> => {
|
|
315
|
+
return signExecuteMethod(BitmapWord, this, "getBitPos", params);
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
async multicall<Calls extends BitmapWordTypes.MultiCallParams>(
|
|
320
|
+
calls: Calls
|
|
321
|
+
): Promise<BitmapWordTypes.MultiCallResults<Calls>>;
|
|
322
|
+
async multicall<Callss extends BitmapWordTypes.MultiCallParams[]>(
|
|
323
|
+
callss: Narrow<Callss>
|
|
324
|
+
): Promise<BitmapWordTypes.MulticallReturnType<Callss>>;
|
|
325
|
+
async multicall<
|
|
326
|
+
Callss extends
|
|
327
|
+
| BitmapWordTypes.MultiCallParams
|
|
328
|
+
| BitmapWordTypes.MultiCallParams[]
|
|
329
|
+
>(callss: Callss): Promise<unknown> {
|
|
330
|
+
return await multicallMethods(
|
|
331
|
+
BitmapWord,
|
|
332
|
+
this,
|
|
333
|
+
callss,
|
|
334
|
+
getContractByCodeHash
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/* Autogenerated file. Do not edit manually. */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Address,
|
|
7
|
+
Contract,
|
|
8
|
+
ContractState,
|
|
9
|
+
TestContractResult,
|
|
10
|
+
HexString,
|
|
11
|
+
ContractFactory,
|
|
12
|
+
EventSubscribeOptions,
|
|
13
|
+
EventSubscription,
|
|
14
|
+
CallContractParams,
|
|
15
|
+
CallContractResult,
|
|
16
|
+
TestContractParams,
|
|
17
|
+
ContractEvent,
|
|
18
|
+
subscribeContractEvent,
|
|
19
|
+
subscribeContractEvents,
|
|
20
|
+
testMethod,
|
|
21
|
+
callMethod,
|
|
22
|
+
multicallMethods,
|
|
23
|
+
fetchContractState,
|
|
24
|
+
Asset,
|
|
25
|
+
ContractInstance,
|
|
26
|
+
getContractEventsCurrentCount,
|
|
27
|
+
TestContractParamsWithoutMaps,
|
|
28
|
+
TestContractResultWithoutMaps,
|
|
29
|
+
SignExecuteContractMethodParams,
|
|
30
|
+
SignExecuteScriptTxResult,
|
|
31
|
+
signExecuteMethod,
|
|
32
|
+
addStdIdToFields,
|
|
33
|
+
encodeContractFields,
|
|
34
|
+
Narrow,
|
|
35
|
+
} from "@alephium/web3";
|
|
36
|
+
import { default as BitmapWordDeployerContractJson } from "../BitmapWordDeployer.ral.json";
|
|
37
|
+
import { getContractByCodeHash, registerContract } from "./contracts";
|
|
38
|
+
import * as types from "./types";
|
|
39
|
+
|
|
40
|
+
// Custom types for the contract
|
|
41
|
+
export namespace BitmapWordDeployerTypes {
|
|
42
|
+
export type State = Omit<ContractState<any>, "fields">;
|
|
43
|
+
|
|
44
|
+
export interface CallMethodTable {
|
|
45
|
+
deploy: {
|
|
46
|
+
params: CallContractParams<{ payer: Address }>;
|
|
47
|
+
result: CallContractResult<HexString>;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export type CallMethodParams<T extends keyof CallMethodTable> =
|
|
51
|
+
CallMethodTable[T]["params"];
|
|
52
|
+
export type CallMethodResult<T extends keyof CallMethodTable> =
|
|
53
|
+
CallMethodTable[T]["result"];
|
|
54
|
+
export type MultiCallParams = Partial<{
|
|
55
|
+
[Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
|
|
56
|
+
}>;
|
|
57
|
+
export type MultiCallResults<T extends MultiCallParams> = {
|
|
58
|
+
[MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
|
|
59
|
+
? CallMethodTable[MaybeName]["result"]
|
|
60
|
+
: undefined;
|
|
61
|
+
};
|
|
62
|
+
export type MulticallReturnType<Callss extends MultiCallParams[]> = {
|
|
63
|
+
[index in keyof Callss]: MultiCallResults<Callss[index]>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export interface SignExecuteMethodTable {
|
|
67
|
+
deploy: {
|
|
68
|
+
params: SignExecuteContractMethodParams<{ payer: Address }>;
|
|
69
|
+
result: SignExecuteScriptTxResult;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
|
|
73
|
+
SignExecuteMethodTable[T]["params"];
|
|
74
|
+
export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
|
|
75
|
+
SignExecuteMethodTable[T]["result"];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
class Factory extends ContractFactory<BitmapWordDeployerInstance, {}> {
|
|
79
|
+
encodeFields() {
|
|
80
|
+
return encodeContractFields({}, this.contract.fieldsSig, types.AllStructs);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
at(address: string): BitmapWordDeployerInstance {
|
|
84
|
+
return new BitmapWordDeployerInstance(address);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
tests = {
|
|
88
|
+
deploy: async (
|
|
89
|
+
params: Omit<
|
|
90
|
+
TestContractParamsWithoutMaps<never, { payer: Address }>,
|
|
91
|
+
"initialFields"
|
|
92
|
+
>
|
|
93
|
+
): Promise<TestContractResultWithoutMaps<HexString>> => {
|
|
94
|
+
return testMethod(this, "deploy", params, getContractByCodeHash);
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
stateForTest(initFields: {}, asset?: Asset, address?: string) {
|
|
99
|
+
return this.stateForTest_(initFields, asset, address, undefined);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Use this object to test and deploy the contract
|
|
104
|
+
export const BitmapWordDeployer = new Factory(
|
|
105
|
+
Contract.fromJson(
|
|
106
|
+
BitmapWordDeployerContractJson,
|
|
107
|
+
"",
|
|
108
|
+
"082de32f22857e094db5658611a1d2ba23e792a7f23a548525e6de2784f2a70b",
|
|
109
|
+
types.AllStructs
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
registerContract(BitmapWordDeployer);
|
|
113
|
+
|
|
114
|
+
// Use this class to interact with the blockchain
|
|
115
|
+
export class BitmapWordDeployerInstance extends ContractInstance {
|
|
116
|
+
constructor(address: Address) {
|
|
117
|
+
super(address);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async fetchState(): Promise<BitmapWordDeployerTypes.State> {
|
|
121
|
+
return fetchContractState(BitmapWordDeployer, this);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
view = {
|
|
125
|
+
deploy: async (
|
|
126
|
+
params: BitmapWordDeployerTypes.CallMethodParams<"deploy">
|
|
127
|
+
): Promise<BitmapWordDeployerTypes.CallMethodResult<"deploy">> => {
|
|
128
|
+
return callMethod(
|
|
129
|
+
BitmapWordDeployer,
|
|
130
|
+
this,
|
|
131
|
+
"deploy",
|
|
132
|
+
params,
|
|
133
|
+
getContractByCodeHash
|
|
134
|
+
);
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
transact = {
|
|
139
|
+
deploy: async (
|
|
140
|
+
params: BitmapWordDeployerTypes.SignExecuteMethodParams<"deploy">
|
|
141
|
+
): Promise<BitmapWordDeployerTypes.SignExecuteMethodResult<"deploy">> => {
|
|
142
|
+
return signExecuteMethod(BitmapWordDeployer, this, "deploy", params);
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
async multicall<Calls extends BitmapWordDeployerTypes.MultiCallParams>(
|
|
147
|
+
calls: Calls
|
|
148
|
+
): Promise<BitmapWordDeployerTypes.MultiCallResults<Calls>>;
|
|
149
|
+
async multicall<Callss extends BitmapWordDeployerTypes.MultiCallParams[]>(
|
|
150
|
+
callss: Narrow<Callss>
|
|
151
|
+
): Promise<BitmapWordDeployerTypes.MulticallReturnType<Callss>>;
|
|
152
|
+
async multicall<
|
|
153
|
+
Callss extends
|
|
154
|
+
| BitmapWordDeployerTypes.MultiCallParams
|
|
155
|
+
| BitmapWordDeployerTypes.MultiCallParams[]
|
|
156
|
+
>(callss: Callss): Promise<unknown> {
|
|
157
|
+
return await multicallMethods(
|
|
158
|
+
BitmapWordDeployer,
|
|
159
|
+
this,
|
|
160
|
+
callss,
|
|
161
|
+
getContractByCodeHash
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|