@provable-games/metagame-sdk 0.1.0 → 0.1.2
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/extensions-BskkhEHk.d.cts +101 -0
- package/dist/extensions-BskkhEHk.d.ts +101 -0
- package/dist/index.cjs +1071 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +489 -0
- package/dist/index.d.ts +489 -0
- package/dist/index.js +1015 -0
- package/dist/index.js.map +1 -0
- package/dist/prizeAggregation-CHwIJzXr.d.cts +325 -0
- package/dist/prizeAggregation-CHwIJzXr.d.ts +325 -0
- package/dist/react.cjs +918 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +300 -0
- package/dist/react.d.ts +300 -0
- package/dist/react.js +906 -0
- package/dist/react.js.map +1 -0
- package/dist/rpc.cjs +161 -0
- package/dist/rpc.cjs.map +1 -0
- package/dist/rpc.d.cts +48 -0
- package/dist/rpc.d.ts +48 -0
- package/dist/rpc.js +146 -0
- package/dist/rpc.js.map +1 -0
- package/package.json +10 -10
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { BigNumberish } from 'starknet';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* RPC calls for EGS entry requirement extensions.
|
|
5
|
+
*
|
|
6
|
+
* These functions call the shared extension contracts on Starknet.
|
|
7
|
+
* They take a starknet.js provider (or any object with callContract)
|
|
8
|
+
* and return parsed results.
|
|
9
|
+
*
|
|
10
|
+
* Every metagame that uses the entry requirement system needs these
|
|
11
|
+
* same calls — they're not app-specific, they call the same contracts.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Minimal provider interface — anything with callContract works */
|
|
15
|
+
interface StarknetCallProvider {
|
|
16
|
+
callContract(call: {
|
|
17
|
+
contractAddress: string;
|
|
18
|
+
entrypoint: string;
|
|
19
|
+
calldata: string[];
|
|
20
|
+
}): Promise<string[]>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check if a player has a valid entry for an extension-gated event.
|
|
24
|
+
*
|
|
25
|
+
* Calls `valid_entry(context_id, player_address, qualification)` on the
|
|
26
|
+
* extension contract.
|
|
27
|
+
*
|
|
28
|
+
* @param provider - Starknet RPC provider
|
|
29
|
+
* @param extensionAddress - The extension contract address
|
|
30
|
+
* @param contextId - The metagame event ID (tournament ID, quest ID, etc.)
|
|
31
|
+
* @param playerAddress - The player's address
|
|
32
|
+
* @param qualification - Proof data (felt252 array)
|
|
33
|
+
* @returns Whether the entry is valid
|
|
34
|
+
*/
|
|
35
|
+
declare function checkExtensionValidEntry(provider: StarknetCallProvider, extensionAddress: string, contextId: BigNumberish, playerAddress: string, qualification: string[]): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Get the number of entries left for a player via an extension.
|
|
38
|
+
*
|
|
39
|
+
* Calls `entries_left(context_id, player_address, qualification)` on the
|
|
40
|
+
* extension contract. Returns null if the extension has no entry limit
|
|
41
|
+
* (Option::None).
|
|
42
|
+
*
|
|
43
|
+
* @returns Number of entries remaining, or null if unlimited
|
|
44
|
+
*/
|
|
45
|
+
declare function getExtensionEntriesLeft(provider: StarknetCallProvider, extensionAddress: string, contextId: BigNumberish, playerAddress: string, qualification: string[]): Promise<number | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Check if a player's entry should be banned via an extension.
|
|
48
|
+
*
|
|
49
|
+
* Calls `should_ban(context_id, game_token_id, current_owner, proof)`.
|
|
50
|
+
*
|
|
51
|
+
* @param gameTokenId - The game token ID to check (felt252)
|
|
52
|
+
* @param currentOwner - Current owner of the game token
|
|
53
|
+
* @param proof - Ban proof data (felt252 array)
|
|
54
|
+
* @returns Whether the entry should be banned
|
|
55
|
+
*/
|
|
56
|
+
declare function checkExtensionShouldBan(provider: StarknetCallProvider, extensionAddress: string, contextId: BigNumberish, gameTokenId: string, currentOwner: string, proof: string[]): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Get the context owner for an entry requirement extension contract.
|
|
59
|
+
*
|
|
60
|
+
* Extensions are multi-tenant: each context_id has its own owner
|
|
61
|
+
* (set by the first caller to configure that context via add_config).
|
|
62
|
+
*
|
|
63
|
+
* @param provider - Starknet RPC provider
|
|
64
|
+
* @param extensionAddress - The extension contract address
|
|
65
|
+
* @param contextId - The metagame event ID (tournament ID, quest ID, etc.)
|
|
66
|
+
* @returns The owner address for that context, or empty string if unclaimed
|
|
67
|
+
*/
|
|
68
|
+
declare function getEntryRequirementContextOwner(provider: StarknetCallProvider, extensionAddress: string, contextId: BigNumberish): Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Get all trove IDs owned by a user from the Opus Abbot contract.
|
|
71
|
+
*
|
|
72
|
+
* @param provider - Starknet RPC provider
|
|
73
|
+
* @param userAddress - The user's address
|
|
74
|
+
* @param abbotAddress - Override Abbot address (defaults to mainnet)
|
|
75
|
+
* @returns Array of trove IDs
|
|
76
|
+
*/
|
|
77
|
+
declare function getUserTroveIds(provider: StarknetCallProvider, userAddress: BigNumberish, abbotAddress?: string): Promise<bigint[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Get a trove's debt from the Opus Shrine contract.
|
|
80
|
+
*
|
|
81
|
+
* Calls `get_trove_health(trove_id)` which returns [value, threshold, ltv, debt].
|
|
82
|
+
* We extract the debt (18 decimals, denominated in CASH which is 1:1 USD).
|
|
83
|
+
*
|
|
84
|
+
* @param provider - Starknet RPC provider
|
|
85
|
+
* @param troveId - The trove ID
|
|
86
|
+
* @param shrineAddress - Override Shrine address (defaults to mainnet)
|
|
87
|
+
* @returns Debt amount in CASH (18 decimals), or null on error
|
|
88
|
+
*/
|
|
89
|
+
declare function getTroveDebt(provider: StarknetCallProvider, troveId: BigNumberish, shrineAddress?: string): Promise<bigint | null>;
|
|
90
|
+
/**
|
|
91
|
+
* Get total debt across all of a user's troves.
|
|
92
|
+
*
|
|
93
|
+
* Convenience function that calls getUserTroveIds then getTroveDebt for each.
|
|
94
|
+
*
|
|
95
|
+
* @param provider - Starknet RPC provider
|
|
96
|
+
* @param userAddress - The user's address
|
|
97
|
+
* @returns Total debt in CASH (18 decimals)
|
|
98
|
+
*/
|
|
99
|
+
declare function getUserTotalTroveDebt(provider: StarknetCallProvider, userAddress: BigNumberish, abbotAddress?: string, shrineAddress?: string): Promise<bigint>;
|
|
100
|
+
|
|
101
|
+
export { type StarknetCallProvider as S, checkExtensionValidEntry as a, getExtensionEntriesLeft as b, checkExtensionShouldBan as c, getTroveDebt as d, getUserTotalTroveDebt as e, getUserTroveIds as f, getEntryRequirementContextOwner as g };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { BigNumberish } from 'starknet';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* RPC calls for EGS entry requirement extensions.
|
|
5
|
+
*
|
|
6
|
+
* These functions call the shared extension contracts on Starknet.
|
|
7
|
+
* They take a starknet.js provider (or any object with callContract)
|
|
8
|
+
* and return parsed results.
|
|
9
|
+
*
|
|
10
|
+
* Every metagame that uses the entry requirement system needs these
|
|
11
|
+
* same calls — they're not app-specific, they call the same contracts.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Minimal provider interface — anything with callContract works */
|
|
15
|
+
interface StarknetCallProvider {
|
|
16
|
+
callContract(call: {
|
|
17
|
+
contractAddress: string;
|
|
18
|
+
entrypoint: string;
|
|
19
|
+
calldata: string[];
|
|
20
|
+
}): Promise<string[]>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check if a player has a valid entry for an extension-gated event.
|
|
24
|
+
*
|
|
25
|
+
* Calls `valid_entry(context_id, player_address, qualification)` on the
|
|
26
|
+
* extension contract.
|
|
27
|
+
*
|
|
28
|
+
* @param provider - Starknet RPC provider
|
|
29
|
+
* @param extensionAddress - The extension contract address
|
|
30
|
+
* @param contextId - The metagame event ID (tournament ID, quest ID, etc.)
|
|
31
|
+
* @param playerAddress - The player's address
|
|
32
|
+
* @param qualification - Proof data (felt252 array)
|
|
33
|
+
* @returns Whether the entry is valid
|
|
34
|
+
*/
|
|
35
|
+
declare function checkExtensionValidEntry(provider: StarknetCallProvider, extensionAddress: string, contextId: BigNumberish, playerAddress: string, qualification: string[]): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Get the number of entries left for a player via an extension.
|
|
38
|
+
*
|
|
39
|
+
* Calls `entries_left(context_id, player_address, qualification)` on the
|
|
40
|
+
* extension contract. Returns null if the extension has no entry limit
|
|
41
|
+
* (Option::None).
|
|
42
|
+
*
|
|
43
|
+
* @returns Number of entries remaining, or null if unlimited
|
|
44
|
+
*/
|
|
45
|
+
declare function getExtensionEntriesLeft(provider: StarknetCallProvider, extensionAddress: string, contextId: BigNumberish, playerAddress: string, qualification: string[]): Promise<number | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Check if a player's entry should be banned via an extension.
|
|
48
|
+
*
|
|
49
|
+
* Calls `should_ban(context_id, game_token_id, current_owner, proof)`.
|
|
50
|
+
*
|
|
51
|
+
* @param gameTokenId - The game token ID to check (felt252)
|
|
52
|
+
* @param currentOwner - Current owner of the game token
|
|
53
|
+
* @param proof - Ban proof data (felt252 array)
|
|
54
|
+
* @returns Whether the entry should be banned
|
|
55
|
+
*/
|
|
56
|
+
declare function checkExtensionShouldBan(provider: StarknetCallProvider, extensionAddress: string, contextId: BigNumberish, gameTokenId: string, currentOwner: string, proof: string[]): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Get the context owner for an entry requirement extension contract.
|
|
59
|
+
*
|
|
60
|
+
* Extensions are multi-tenant: each context_id has its own owner
|
|
61
|
+
* (set by the first caller to configure that context via add_config).
|
|
62
|
+
*
|
|
63
|
+
* @param provider - Starknet RPC provider
|
|
64
|
+
* @param extensionAddress - The extension contract address
|
|
65
|
+
* @param contextId - The metagame event ID (tournament ID, quest ID, etc.)
|
|
66
|
+
* @returns The owner address for that context, or empty string if unclaimed
|
|
67
|
+
*/
|
|
68
|
+
declare function getEntryRequirementContextOwner(provider: StarknetCallProvider, extensionAddress: string, contextId: BigNumberish): Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Get all trove IDs owned by a user from the Opus Abbot contract.
|
|
71
|
+
*
|
|
72
|
+
* @param provider - Starknet RPC provider
|
|
73
|
+
* @param userAddress - The user's address
|
|
74
|
+
* @param abbotAddress - Override Abbot address (defaults to mainnet)
|
|
75
|
+
* @returns Array of trove IDs
|
|
76
|
+
*/
|
|
77
|
+
declare function getUserTroveIds(provider: StarknetCallProvider, userAddress: BigNumberish, abbotAddress?: string): Promise<bigint[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Get a trove's debt from the Opus Shrine contract.
|
|
80
|
+
*
|
|
81
|
+
* Calls `get_trove_health(trove_id)` which returns [value, threshold, ltv, debt].
|
|
82
|
+
* We extract the debt (18 decimals, denominated in CASH which is 1:1 USD).
|
|
83
|
+
*
|
|
84
|
+
* @param provider - Starknet RPC provider
|
|
85
|
+
* @param troveId - The trove ID
|
|
86
|
+
* @param shrineAddress - Override Shrine address (defaults to mainnet)
|
|
87
|
+
* @returns Debt amount in CASH (18 decimals), or null on error
|
|
88
|
+
*/
|
|
89
|
+
declare function getTroveDebt(provider: StarknetCallProvider, troveId: BigNumberish, shrineAddress?: string): Promise<bigint | null>;
|
|
90
|
+
/**
|
|
91
|
+
* Get total debt across all of a user's troves.
|
|
92
|
+
*
|
|
93
|
+
* Convenience function that calls getUserTroveIds then getTroveDebt for each.
|
|
94
|
+
*
|
|
95
|
+
* @param provider - Starknet RPC provider
|
|
96
|
+
* @param userAddress - The user's address
|
|
97
|
+
* @returns Total debt in CASH (18 decimals)
|
|
98
|
+
*/
|
|
99
|
+
declare function getUserTotalTroveDebt(provider: StarknetCallProvider, userAddress: BigNumberish, abbotAddress?: string, shrineAddress?: string): Promise<bigint>;
|
|
100
|
+
|
|
101
|
+
export { type StarknetCallProvider as S, checkExtensionValidEntry as a, getExtensionEntriesLeft as b, checkExtensionShouldBan as c, getTroveDebt as d, getUserTotalTroveDebt as e, getUserTroveIds as f, getEntryRequirementContextOwner as g };
|