@snapshot-labs/snapshot.js 0.12.57 → 0.12.58
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/dist/snapshot.cjs.js +33 -2
- package/dist/snapshot.esm.js +33 -2
- package/dist/snapshot.min.js +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/utils.ts +40 -2
package/dist/src/utils.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export declare function validateSchema(schema: any, data: any, options?: validat
|
|
|
31
31
|
export declare function getEnsTextRecord(ens: string, record: string, network?: string, options?: any): Promise<string | null>;
|
|
32
32
|
export declare function getSpaceUri(id: string, network?: string, options?: any): Promise<string | null>;
|
|
33
33
|
export declare function getEnsOwner(ens: string, network?: string, options?: any): Promise<string>;
|
|
34
|
+
export declare function getShibariumNameOwner(id: string, network: string): Promise<string>;
|
|
34
35
|
export declare function getSpaceController(id: string, network?: string, options?: any): Promise<string>;
|
|
35
36
|
export declare function clone(item: any): any;
|
|
36
37
|
export declare function sleep(time: any): Promise<unknown>;
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -716,9 +716,9 @@ export async function getEnsOwner(
|
|
|
716
716
|
return owner || EMPTY_ADDRESS;
|
|
717
717
|
}
|
|
718
718
|
|
|
719
|
-
|
|
719
|
+
async function getEnsSpaceController(
|
|
720
720
|
id: string,
|
|
721
|
-
network
|
|
721
|
+
network: string,
|
|
722
722
|
options: any = {}
|
|
723
723
|
): Promise<string> {
|
|
724
724
|
const spaceUri = await getSpaceUri(id, network, options);
|
|
@@ -735,6 +735,44 @@ export async function getSpaceController(
|
|
|
735
735
|
return await getEnsOwner(id, network, options);
|
|
736
736
|
}
|
|
737
737
|
|
|
738
|
+
export async function getShibariumNameOwner(
|
|
739
|
+
id: string,
|
|
740
|
+
network: string
|
|
741
|
+
): Promise<string> {
|
|
742
|
+
if (!id.endsWith('.shib')) {
|
|
743
|
+
return EMPTY_ADDRESS;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
const response = await fetch('https://stamp.fyi', {
|
|
747
|
+
method: 'POST',
|
|
748
|
+
headers: {
|
|
749
|
+
'Content-Type': 'application/json'
|
|
750
|
+
},
|
|
751
|
+
body: JSON.stringify({
|
|
752
|
+
method: 'get_owner',
|
|
753
|
+
params: id,
|
|
754
|
+
network
|
|
755
|
+
})
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
const data = await response.json();
|
|
759
|
+
return data.result;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
export async function getSpaceController(
|
|
763
|
+
id: string,
|
|
764
|
+
network = '1',
|
|
765
|
+
options: any = {}
|
|
766
|
+
): Promise<string> {
|
|
767
|
+
if (['1', '11155111'].includes(network)) {
|
|
768
|
+
return getEnsSpaceController(id, network, options);
|
|
769
|
+
} else if (['109', '157'].includes(network)) {
|
|
770
|
+
return getShibariumNameOwner(id, network);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
throw new Error(`Network not supported: ${network}`);
|
|
774
|
+
}
|
|
775
|
+
|
|
738
776
|
export function clone(item) {
|
|
739
777
|
return JSON.parse(JSON.stringify(item));
|
|
740
778
|
}
|