@interest-protocol/registry-sdk 1.0.0
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 +59 -0
- package/dist/addresses/__tests__/evm.test.d.ts +2 -0
- package/dist/addresses/__tests__/evm.test.d.ts.map +1 -0
- package/dist/addresses/__tests__/solana.test.d.ts +2 -0
- package/dist/addresses/__tests__/solana.test.d.ts.map +1 -0
- package/dist/addresses/__tests__/sui.test.d.ts +2 -0
- package/dist/addresses/__tests__/sui.test.d.ts.map +1 -0
- package/dist/addresses/evm.d.ts +15 -0
- package/dist/addresses/evm.d.ts.map +1 -0
- package/dist/addresses/index.d.ts +4 -0
- package/dist/addresses/index.d.ts.map +1 -0
- package/dist/addresses/solana.d.ts +16 -0
- package/dist/addresses/solana.d.ts.map +1 -0
- package/dist/addresses/sui.d.ts +14 -0
- package/dist/addresses/sui.d.ts.map +1 -0
- package/dist/constants.d.ts +38 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6368 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6346 -0
- package/dist/index.mjs.map +1 -0
- package/dist/registry.d.ts +38 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.types.d.ts +59 -0
- package/dist/registry.types.d.ts.map +1 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @lattice/registry-sdk
|
|
2
|
+
|
|
3
|
+
SDK for mapping external chain addresses to Sui addresses.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Registry, SolanaPubkey, SuiAddress } from '@lattice/registry-sdk';
|
|
15
|
+
|
|
16
|
+
const registry = new Registry({
|
|
17
|
+
suiClient,
|
|
18
|
+
packageId: REGISTRY_PACKAGE_ID,
|
|
19
|
+
registrySharedObjectData,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Link a Solana address
|
|
23
|
+
const tx = registry.linkSolana({
|
|
24
|
+
solanaPubkey: new SolanaPubkey(pubkeyBytes),
|
|
25
|
+
signature,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Lookup Sui address from Solana address
|
|
29
|
+
const suiAddress = await registry.getSuiAddressFromSolana({
|
|
30
|
+
solanaPubkey,
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Address Classes
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// Solana addresses
|
|
38
|
+
const sol = SolanaPubkey.fromBs58('DXbGPsLos...');
|
|
39
|
+
sol.toBs58(); // base58 string
|
|
40
|
+
sol.toHex(); // hex string
|
|
41
|
+
sol.toBytes(); // Uint8Array
|
|
42
|
+
|
|
43
|
+
// Sui addresses
|
|
44
|
+
const sui = SuiAddress.fromHex('0x...');
|
|
45
|
+
sui.toHex(); // hex string
|
|
46
|
+
sui.toBytes(); // Uint8Array
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Development
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
bun run build # Build package
|
|
53
|
+
bun run test # Run tests
|
|
54
|
+
bun run lint # Run linter
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Documentation
|
|
58
|
+
|
|
59
|
+
See [../CLAUDE.md](../CLAUDE.md) for SDK architecture patterns.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm.test.d.ts","sourceRoot":"","sources":["../../../src/addresses/__tests__/evm.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana.test.d.ts","sourceRoot":"","sources":["../../../src/addresses/__tests__/solana.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sui.test.d.ts","sourceRoot":"","sources":["../../../src/addresses/__tests__/sui.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
export declare class EvmAddress {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(bytes: Uint8Array);
|
|
5
|
+
static fromHex(hexAddress: string): EvmAddress;
|
|
6
|
+
static fromBytes(bytes: Uint8Array): EvmAddress;
|
|
7
|
+
static isValidHex(hexAddress: string): boolean;
|
|
8
|
+
static readonly ZERO: EvmAddress;
|
|
9
|
+
equals(other: EvmAddress): boolean;
|
|
10
|
+
toHex(): Address;
|
|
11
|
+
toBytes(): Uint8Array;
|
|
12
|
+
toString(): string;
|
|
13
|
+
toJSON(): string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=evm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/addresses/evm.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAqC,MAAM,MAAM,CAAC;AAIvE,qBAAa,UAAU;;gBAGP,KAAK,EAAE,UAAU;IAQ7B,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAK9C,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;IAI/C,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAI9C,MAAM,CAAC,QAAQ,CAAC,IAAI,aAAsD;IAE1E,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;IAQlC,KAAK,IAAI,OAAO;IAIhB,OAAO,IAAI,UAAU;IAIrB,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/addresses/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class SolanaPubkey {
|
|
2
|
+
#private;
|
|
3
|
+
constructor(bytes: Uint8Array);
|
|
4
|
+
static fromBs58(bs58Address: string): SolanaPubkey;
|
|
5
|
+
static fromHex(hexAddress: string): SolanaPubkey;
|
|
6
|
+
static isValidBs58(bs58Address: string): boolean;
|
|
7
|
+
static isValidHex(hexAddress: string): boolean;
|
|
8
|
+
static readonly ZERO: SolanaPubkey;
|
|
9
|
+
equals(other: SolanaPubkey): boolean;
|
|
10
|
+
toBs58(): string;
|
|
11
|
+
toHex(): string;
|
|
12
|
+
toBytes(): Uint8Array;
|
|
13
|
+
toString(): string;
|
|
14
|
+
toJSON(): string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=solana.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/addresses/solana.ts"],"names":[],"mappings":"AAMA,qBAAa,YAAY;;gBAGT,KAAK,EAAE,UAAU;IAQ7B,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY;IAIlD,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY;IAIhD,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAShD,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAS9C,MAAM,CAAC,QAAQ,CAAC,IAAI,eAA0D;IAE9E,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO;IAQpC,MAAM,IAAI,MAAM;IAIhB,KAAK,IAAI,MAAM;IAIf,OAAO,IAAI,UAAU;IAIrB,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class SuiAddress {
|
|
2
|
+
#private;
|
|
3
|
+
constructor(input: Uint8Array | string);
|
|
4
|
+
static fromHex(hexAddress: string): SuiAddress;
|
|
5
|
+
static fromBytes(bytes: Uint8Array): SuiAddress;
|
|
6
|
+
static isValidHex(hexAddress: string): boolean;
|
|
7
|
+
static readonly ZERO: SuiAddress;
|
|
8
|
+
equals(other: SuiAddress): boolean;
|
|
9
|
+
toHex(): string;
|
|
10
|
+
toBytes(): Uint8Array;
|
|
11
|
+
toString(): string;
|
|
12
|
+
toJSON(): string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=sui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../src/addresses/sui.ts"],"names":[],"mappings":"AAKA,qBAAa,UAAU;;gBAGP,KAAK,EAAE,UAAU,GAAG,MAAM;IActC,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAI9C,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;IAI/C,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAI9C,MAAM,CAAC,QAAQ,CAAC,IAAI,aAAsD;IAE1E,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;IAQlC,KAAK,IAAI,MAAM;IAIf,OAAO,IAAI,UAAU;IAIrB,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const MAINNET_PACKAGE_ID = "0x0627db9e69f072af2119cbdc744b06216e67bc685d75ead2b0d9a5f7a5e0dca5";
|
|
2
|
+
export declare const SOLANA_PUBKEY_LENGTH = 32;
|
|
3
|
+
export declare const EVM_ADDRESS_LENGTH = 20;
|
|
4
|
+
export declare const SUI_ADDRESS_LENGTH = 32;
|
|
5
|
+
export declare const ED25519_PUBKEY_LENGTH = 32;
|
|
6
|
+
export declare const ED25519_SIGNATURE_LENGTH = 64;
|
|
7
|
+
export declare const SECP256K1_COMPRESSED_PUBKEY_LENGTH = 33;
|
|
8
|
+
export declare const SECP256K1_SIGNATURE_LENGTH = 64;
|
|
9
|
+
export declare const SECP256K1_FLAG = 1;
|
|
10
|
+
export declare const MAX_LINKS_PER_CHAIN = 20;
|
|
11
|
+
export declare const SOLANA_CHAIN = "Solana";
|
|
12
|
+
export declare const EVM_CHAIN = "EVM";
|
|
13
|
+
export declare const Modules: {
|
|
14
|
+
readonly Registry: "registry";
|
|
15
|
+
readonly Inner: "inner";
|
|
16
|
+
readonly Events: "events";
|
|
17
|
+
};
|
|
18
|
+
export declare const Functions: {
|
|
19
|
+
readonly LinkSolana: "link_solana";
|
|
20
|
+
readonly LinkEvm: "link_evm";
|
|
21
|
+
readonly LinkAlias: "link_alias";
|
|
22
|
+
readonly UnlinkSolana: "unlink_solana";
|
|
23
|
+
readonly UnlinkEvm: "unlink_evm";
|
|
24
|
+
readonly UnlinkAlias: "unlink_alias";
|
|
25
|
+
readonly GetSuiForSolana: "get_sui_for_solana";
|
|
26
|
+
readonly GetSuiForEvm: "get_sui_for_evm";
|
|
27
|
+
readonly GetSolanaForSui: "get_solana_for_sui";
|
|
28
|
+
readonly GetEvmForSui: "get_evm_for_sui";
|
|
29
|
+
readonly GetAliases: "get_aliases";
|
|
30
|
+
readonly GetPrimary: "get_primary";
|
|
31
|
+
};
|
|
32
|
+
export declare const REGISTRY_OBJECT_ID = "0xe785fd9e5e8797bec0e5dbace1c4be4c787681f97c9c56ca7444fcc8ba72a330";
|
|
33
|
+
export declare const REGISTRY_INITIAL_SHARED_VERSION = "779879272";
|
|
34
|
+
export declare const REGISTRY_SHARED_OBJECT_DATA: {
|
|
35
|
+
readonly objectId: "0xe785fd9e5e8797bec0e5dbace1c4be4c787681f97c9c56ca7444fcc8ba72a330";
|
|
36
|
+
readonly initialSharedVersion: "779879272";
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,uEACyC,CAAC;AAEzE,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,kCAAkC,KAAK,CAAC;AACrD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,cAAc,IAAO,CAAC;AACnC,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,eAAO,MAAM,YAAY,WAAW,CAAC;AACrC,eAAO,MAAM,SAAS,QAAQ,CAAC;AAE/B,eAAO,MAAM,OAAO;;;;CAIV,CAAC;AAEX,eAAO,MAAM,SAAS;;;;;;;;;;;;;CAaZ,CAAC;AAEX,eAAO,MAAM,kBAAkB,uEACyC,CAAC;AAEzE,eAAO,MAAM,+BAA+B,cAAc,CAAC;AAE3D,eAAO,MAAM,2BAA2B;;;CAG9B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|