-
Notifications
You must be signed in to change notification settings - Fork 4
/
sui.ts
41 lines (38 loc) · 1.02 KB
/
sui.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
import { isHex } from './utils'
/**
* Validate Sui address
* @param address Sui address
* @returns true/false
*/
export const isSuiAddress = (
address: string | undefined,
): address is string => {
if (!address) return false
try {
const length = isHex(address)
return length === 32
} catch (er) {
return false
}
}
/**
* Convert a compressed pubkey to a Sui address
* @param pubkey Compressed pubkey
* @returns Sui address
*/
export { toSuiAddress } from '@desig/supported-chains'
/**
* Add signture to a Sui transaction
* @param transaction The Sui transaction
* @param { sig, addr } signature The product of `Proposal.finalizaSignature` extended the signer address
* @returns
*/
export const addSuiSignature = (
transaction: any,
{ sig, addr }: { sig: Uint8Array; addr: string },
) => {
console.warn(
'There is no available signature adding action in Sui. Read more: https://github.com/MystenLabs/sui/blob/main/sdk/typescript/src/providers/json-rpc-provider.ts#L480',
)
return transaction
}