-
Notifications
You must be signed in to change notification settings - Fork 302
Expand file tree
/
Copy pathiface.ts
More file actions
199 lines (180 loc) · 6 KB
/
iface.ts
File metadata and controls
199 lines (180 loc) · 6 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
199
import {
TransactionExplanation as BaseTransactionExplanation,
TransactionType as BitGoTransactionType,
} from '@bitgo/sdk-core';
import BigNumber from 'bignumber.js';
import {
CallArg,
GasData,
ProgrammableTransaction,
SuiAddress,
SuiObjectRef,
TransactionExpiration,
} from './mystenlab/types';
import { TransactionBlockInput, TransactionType } from './mystenlab/builder';
export enum SuiTransactionType {
Transfer = 'Transfer',
AddStake = 'AddStake',
WithdrawStake = 'WithdrawStake',
CustomTx = 'CustomTx',
TokenTransfer = 'TokenTransfer',
WalrusStakeWithPool = 'WalrusStakeWithPool',
WalrusRequestWithdrawStake = 'WalrusRequestWithdrawStake',
WalrusWithdrawStake = 'WalrusWithdrawStake',
}
export interface TransactionExplanation extends BaseTransactionExplanation {
type: BitGoTransactionType;
}
export type SuiProgrammableTransaction =
| TransferProgrammableTransaction
| StakingProgrammableTransaction
| UnstakingProgrammableTransaction
| CustomProgrammableTransaction
| TokenTransferProgrammableTransaction
| WalrusStakingProgrammableTransaction
| WalrusWithdrawStakeProgrammableTransaction;
export interface TxData {
id?: string;
sender: SuiAddress;
expiration: TransactionExpiration;
gasData: GasData;
kind: {
ProgrammableTransaction: SuiProgrammableTransaction;
};
inputObjects?: SuiObjectRef[];
fundsInAddressBalance?: string;
}
export type TransferProgrammableTransaction =
| ProgrammableTransaction
| {
inputs: CallArg[] | TransactionBlockInput[];
transactions: TransactionType[];
};
export type StakingProgrammableTransaction =
| ProgrammableTransaction
| {
inputs: CallArg[] | TransactionBlockInput[];
transactions: TransactionType[];
};
export type UnstakingProgrammableTransaction =
| ProgrammableTransaction
| {
inputs: CallArg[] | TransactionBlockInput[];
transactions: TransactionType[];
};
export type CustomProgrammableTransaction =
| ProgrammableTransaction
| {
inputs: CallArg[] | TransactionBlockInput[];
transactions: TransactionType[];
};
export type TokenTransferProgrammableTransaction =
| ProgrammableTransaction
| {
inputs: CallArg[] | TransactionBlockInput[];
transactions: TransactionType[];
};
export type WalrusStakingProgrammableTransaction =
| ProgrammableTransaction
| {
inputs: CallArg[] | TransactionBlockInput[];
transactions: TransactionType[];
};
export type WalrusWithdrawStakeProgrammableTransaction =
| ProgrammableTransaction
| {
inputs: CallArg[] | TransactionBlockInput[];
transactions: TransactionType[];
};
export interface SuiTransaction<T = SuiProgrammableTransaction> {
id?: string;
type: SuiTransactionType;
sender: string;
tx: T;
gasData: GasData;
expiration?: TransactionExpiration;
inputObjects?: SuiObjectRef[];
fundsInAddressBalance?: string;
}
export interface RequestAddStake {
amount: number;
validatorAddress: SuiAddress;
}
export interface RequestWithdrawStakedSui {
amount?: number;
stakedSui: SuiObjectRef;
}
export interface RequestWalrusStakeWithPool {
amount: number;
validatorAddress: SuiAddress;
}
export interface RequestWalrusWithdrawStake {
amount?: number;
stakedWal: SuiObjectRef;
}
/**
* Method names for the transaction method. Names change based on the type of transaction e.g 'request_add_delegation_mul_coin' for the staking transaction
*/
export enum MethodNames {
/**
* Add stake to a validator's staking pool.
*
* @see https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui_system.md#function-request_add_stake
*/
RequestAddStake = '::sui_system::request_add_stake',
/**
* Withdraw some portion of a stake from a validator's staking pool.
*
* @see https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui_system.md#function-request_withdraw_stake
*/
RequestWithdrawStake = '::sui_system::request_withdraw_stake',
/**
* Split StakedSui self to two parts, one with principal split_amount, and the remaining principal is left in self.
*
* @see https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/staking_pool.md#0x3_staking_pool_split
*/
StakingPoolSplit = '::staking_pool::split',
/**
* Transfer ownership of obj to recipient.
*
* @see https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/transfer.md#function-public_transfer
*/
PublicTransfer = '::transfer::public_transfer',
/**
* Walrus stake with pool.
*
* @see https://github.com/MystenLabs/walrus-docs/blob/8ba15d67d7ed0e728077e1600866fddd46fd113b/contracts/walrus/sources/staking.move#L289
*/
WalrusStakeWithPool = '::staking::stake_with_pool',
/**
* @see https://github.com/MystenLabs/walrus-docs/blob/9307e66df0ea3f6555cdef78d46aefa62737e216/contracts/walrus/sources/staking.move#L221
*/
WalrusRequestWithdrawStake = '::staking::request_withdraw_stake',
/**
* @see https://github.com/MystenLabs/walrus-docs/blob/9307e66df0ea3f6555cdef78d46aefa62737e216/contracts/walrus/sources/staking.move#L231
*/
WalrusWithdrawStake = '::staking::withdraw_stake',
/**
* @see https://github.com/MystenLabs/walrus-docs/blob/9307e66df0ea3f6555cdef78d46aefa62737e216/contracts/walrus/sources/staking/staked_wal.move#L143
*/
WalrusSplitStakedWal = '::staked_wal::split',
/**
* Redeem funds from the address balance system into a Coin<T> object.
* Used with the BalanceWithdrawal CallArg to spend from address balance.
*
* @see https://docs.sui.io/concepts/sui-move-concepts/address-balance
*/
RedeemFunds = '::coin::redeem_funds',
}
export interface SuiObjectInfo extends SuiObjectRef {
/** balance */
balance: BigNumber;
}
export interface SuiBalanceInfo {
/** Total balance combining coin object balance and address balance */
totalBalance: string;
/** Balance held in coin objects (UTXO-style Coin<T> objects) */
coinObjectBalance: string;
/** Balance held in the address balance system (not in coin objects) */
fundsInAddressBalance: string;
}