@peeramid-labs/sdk 3.15.0 → 3.16.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 +34 -0
- package/cli/abis/ArguableVotingTournament.js +10 -0
- package/cli/abis/ArguableVotingTournament.js.map +1 -1
- package/cli/abis/MAODistribution.js +16 -0
- package/cli/abis/MAODistribution.js.map +1 -1
- package/cli/abis/MockShortStrings.js +37 -0
- package/cli/abis/MockShortStrings.js.map +1 -0
- package/cli/abis/Multipass.js +7 -1
- package/cli/abis/Multipass.js.map +1 -1
- package/cli/abis/PausableUpgradeable.js +79 -0
- package/cli/abis/PausableUpgradeable.js.map +1 -0
- package/cli/abis/RankToken.js +38 -0
- package/cli/abis/RankToken.js.map +1 -1
- package/cli/abis/RankifyDiamondInstance.js +1987 -756
- package/cli/abis/RankifyDiamondInstance.js.map +1 -1
- package/cli/abis/RankifyInstanceInit.js +190 -0
- package/cli/abis/RankifyInstanceInit.js.map +1 -1
- package/cli/abis/RankifyInstanceMainFacet.js +38 -0
- package/cli/abis/RankifyInstanceMainFacet.js.map +1 -1
- package/cli/abis/RankifyOwnersFacet.js +78 -0
- package/cli/abis/RankifyOwnersFacet.js.map +1 -0
- package/cli/abis/UBI.js +775 -0
- package/cli/abis/UBI.js.map +1 -0
- package/cli/abis/index.js +19 -1
- package/cli/abis/index.js.map +1 -1
- package/cli/abis/superinterface.js +3049 -0
- package/cli/abis/superinterface.js.map +1 -0
- package/cli/cli/commands/blockchain/mine.js +0 -2
- package/cli/cli/commands/blockchain/mine.js.map +1 -1
- package/cli/cli/commands/fellowship/game/create.js +45 -1
- package/cli/cli/commands/fellowship/game/create.js.map +1 -1
- package/cli/cli/commands/fellowship/game/end-proposing.js +2 -2
- package/cli/cli/commands/fellowship/game/end-proposing.js.map +1 -1
- package/cli/cli/commands/fellowship/game/end-voting.js +2 -2
- package/cli/cli/commands/fellowship/game/end-voting.js.map +1 -1
- package/cli/cli/commands/fellowship/game/join.js +2 -1
- package/cli/cli/commands/fellowship/game/join.js.map +1 -1
- package/cli/cli/commands/fellowship/game/start.js +0 -17
- package/cli/cli/commands/fellowship/game/start.js.map +1 -1
- package/cli/cli/commands/fellowship/game/vote.js +2 -1
- package/cli/cli/commands/fellowship/game/vote.js.map +1 -1
- package/cli/cli/commands/fellowship/gameMaster/add.js +52 -0
- package/cli/cli/commands/fellowship/gameMaster/add.js.map +1 -0
- package/cli/cli/commands/fellowship/gameMaster/index.js +7 -0
- package/cli/cli/commands/fellowship/gameMaster/index.js.map +1 -0
- package/cli/cli/commands/fellowship/index.js +3 -1
- package/cli/cli/commands/fellowship/index.js.map +1 -1
- package/cli/cli/commands/instances/list.js +6 -0
- package/cli/cli/commands/instances/list.js.map +1 -1
- package/cli/cli/commands/multipass/contract.js +26 -0
- package/cli/cli/commands/multipass/contract.js.map +1 -1
- package/cli/cli/commands/multipass/domain.js +44 -1
- package/cli/cli/commands/multipass/domain.js.map +1 -1
- package/cli/cli/commands/multipass/domains.js +16 -2
- package/cli/cli/commands/multipass/domains.js.map +1 -1
- package/cli/cli/playbooks/demo-script.js +192 -0
- package/cli/cli/playbooks/demo-script.js.map +1 -0
- package/cli/cli/playbooks/demoScript.js +190 -0
- package/cli/cli/playbooks/demoScript.js.map +1 -0
- package/cli/cli/playbooks/initGameMaster.js +50 -0
- package/cli/cli/playbooks/initGameMaster.js.map +1 -0
- package/cli/cli/playbooks/playbookRunner.js +80 -0
- package/cli/cli/playbooks/playbookRunner.js.map +1 -0
- package/cli/cli/playbooks/push-game-to-next-phase.js +162 -0
- package/cli/cli/playbooks/push-game-to-next-phase.js.map +1 -0
- package/cli/cli/playbooks/utils.js +210 -0
- package/cli/cli/playbooks/utils.js.map +1 -0
- package/cli/multipass/MultipassBase.js +38 -70
- package/cli/multipass/MultipassBase.js.map +1 -1
- package/cli/multipass/Owner.js +34 -16
- package/cli/multipass/Owner.js.map +1 -1
- package/cli/rankify/GameMaster.js.map +1 -1
- package/cli/rankify/InstanceAdmininstrative.js +70 -0
- package/cli/rankify/InstanceAdmininstrative.js.map +1 -0
- package/cli/rankify/InstanceBase.js +14 -0
- package/cli/rankify/InstanceBase.js.map +1 -1
- package/cli/rankify/Player.js +24 -1
- package/cli/rankify/Player.js.map +1 -1
- package/cli/types.js +7 -1
- package/cli/types.js.map +1 -1
- package/cli/utils/EnvioGraphQLClient.js +468 -0
- package/cli/utils/EnvioGraphQLClient.js.map +1 -1
- package/cli/utils/artifacts.js +15 -3
- package/cli/utils/artifacts.js.map +1 -1
- package/cli/utils/chainMapping.js +0 -1
- package/cli/utils/chainMapping.js.map +1 -1
- package/docs/classes/EnvioGraphQLClient.md +368 -0
- package/docs/classes/GameMaster.md +19 -0
- package/docs/classes/InstanceBase.md +19 -0
- package/docs/classes/InstancePlayer.md +22 -8
- package/docs/classes/InstanceUBI.md +1591 -0
- package/docs/classes/Multipass.md +31 -4
- package/docs/classes/MultipassBase.md +26 -3
- package/docs/docs/classes/EnvioGraphQLClient.md +368 -0
- package/docs/docs/classes/GameMaster.md +19 -0
- package/docs/docs/classes/InstanceBase.md +19 -0
- package/docs/docs/classes/InstancePlayer.md +22 -8
- package/docs/docs/classes/InstanceUBI.md +1591 -0
- package/docs/docs/classes/Multipass.md +31 -4
- package/docs/docs/classes/MultipassBase.md +26 -3
- package/docs/docs/enums/ContractTypes.md +27 -0
- package/docs/docs/index.md +24 -8
- package/docs/docs/interfaces/ContractCondition.md +41 -0
- package/docs/docs/interfaces/DailyProposal.md +36 -0
- package/docs/docs/interfaces/JoinRequirementsInput.md +20 -0
- package/docs/docs/interfaces/ProposalGlobalStats.md +29 -0
- package/docs/docs/interfaces/TransactionProperties.md +20 -0
- package/docs/docs/interfaces/UBIParams.md +29 -0
- package/docs/docs/interfaces/UserState.md +22 -0
- package/docs/docs/interfaces/VoteElement.md +22 -0
- package/docs/docs/interfaces/configSmartRequirement.md +34 -0
- package/docs/docs/interfaces/numericConditon.md +41 -0
- package/docs/enums/ContractTypes.md +27 -0
- package/docs/index.md +24 -8
- package/docs/interfaces/ContractCondition.md +41 -0
- package/docs/interfaces/DailyProposal.md +36 -0
- package/docs/interfaces/JoinRequirementsInput.md +20 -0
- package/docs/interfaces/ProposalGlobalStats.md +29 -0
- package/docs/interfaces/TransactionProperties.md +20 -0
- package/docs/interfaces/UBIParams.md +29 -0
- package/docs/interfaces/UserState.md +22 -0
- package/docs/interfaces/VoteElement.md +22 -0
- package/docs/interfaces/configSmartRequirement.md +34 -0
- package/docs/interfaces/numericConditon.md +41 -0
- package/lib.commonjs/abis/ArguableVotingTournament.d.ts +8 -0
- package/lib.commonjs/abis/ArguableVotingTournament.d.ts.map +1 -1
- package/lib.commonjs/abis/ArguableVotingTournament.js +10 -0
- package/lib.commonjs/abis/ArguableVotingTournament.js.map +1 -1
- package/lib.commonjs/abis/MAODistribution.d.ts +12 -0
- package/lib.commonjs/abis/MAODistribution.d.ts.map +1 -1
- package/lib.commonjs/abis/MAODistribution.js +16 -0
- package/lib.commonjs/abis/MAODistribution.js.map +1 -1
- package/lib.commonjs/abis/MockShortStrings.d.ts +25 -0
- package/lib.commonjs/abis/MockShortStrings.d.ts.map +1 -0
- package/lib.commonjs/abis/MockShortStrings.js +37 -0
- package/lib.commonjs/abis/MockShortStrings.js.map +1 -0
- package/lib.commonjs/abis/Multipass.d.ts +5 -1
- package/lib.commonjs/abis/Multipass.d.ts.map +1 -1
- package/lib.commonjs/abis/Multipass.js +7 -1
- package/lib.commonjs/abis/Multipass.js.map +1 -1
- package/lib.commonjs/abis/PausableUpgradeable.d.ts +59 -0
- package/lib.commonjs/abis/PausableUpgradeable.d.ts.map +1 -0
- package/lib.commonjs/abis/PausableUpgradeable.js +79 -0
- package/lib.commonjs/abis/PausableUpgradeable.js.map +1 -0
- package/lib.commonjs/abis/RankToken.d.ts +30 -0
- package/lib.commonjs/abis/RankToken.d.ts.map +1 -1
- package/lib.commonjs/abis/RankToken.js +38 -0
- package/lib.commonjs/abis/RankToken.js.map +1 -1
- package/lib.commonjs/abis/RankifyDiamondInstance.d.ts +970 -9
- package/lib.commonjs/abis/RankifyDiamondInstance.d.ts.map +1 -1
- package/lib.commonjs/abis/RankifyDiamondInstance.js +1987 -756
- package/lib.commonjs/abis/RankifyDiamondInstance.js.map +1 -1
- package/lib.commonjs/abis/RankifyInstanceInit.d.ts +150 -0
- package/lib.commonjs/abis/RankifyInstanceInit.d.ts.map +1 -1
- package/lib.commonjs/abis/RankifyInstanceInit.js +190 -0
- package/lib.commonjs/abis/RankifyInstanceInit.js.map +1 -1
- package/lib.commonjs/abis/RankifyInstanceMainFacet.d.ts +30 -0
- package/lib.commonjs/abis/RankifyInstanceMainFacet.d.ts.map +1 -1
- package/lib.commonjs/abis/RankifyInstanceMainFacet.js +38 -0
- package/lib.commonjs/abis/RankifyInstanceMainFacet.js.map +1 -1
- package/lib.commonjs/abis/RankifyOwnersFacet.d.ts +57 -0
- package/lib.commonjs/abis/RankifyOwnersFacet.d.ts.map +1 -0
- package/lib.commonjs/abis/RankifyOwnersFacet.js +78 -0
- package/lib.commonjs/abis/RankifyOwnersFacet.js.map +1 -0
- package/lib.commonjs/abis/UBI.d.ts +601 -0
- package/lib.commonjs/abis/UBI.d.ts.map +1 -0
- package/lib.commonjs/abis/UBI.js +775 -0
- package/lib.commonjs/abis/UBI.js.map +1 -0
- package/lib.commonjs/abis/index.d.ts +1935 -1
- package/lib.commonjs/abis/index.d.ts.map +1 -1
- package/lib.commonjs/abis/index.js +19 -1
- package/lib.commonjs/abis/index.js.map +1 -1
- package/lib.commonjs/abis/superinterface.d.ts +3 -0
- package/lib.commonjs/abis/superinterface.d.ts.map +1 -0
- package/lib.commonjs/abis/superinterface.js +3049 -0
- package/lib.commonjs/abis/superinterface.js.map +1 -0
- package/lib.commonjs/index.d.ts +2 -0
- package/lib.commonjs/index.d.ts.map +1 -1
- package/lib.commonjs/index.js +3 -1
- package/lib.commonjs/index.js.map +1 -1
- package/lib.commonjs/multipass/MultipassBase.d.ts +18 -4
- package/lib.commonjs/multipass/MultipassBase.d.ts.map +1 -1
- package/lib.commonjs/multipass/MultipassBase.js +39 -71
- package/lib.commonjs/multipass/MultipassBase.js.map +1 -1
- package/lib.commonjs/multipass/Owner.d.ts +22 -8
- package/lib.commonjs/multipass/Owner.d.ts.map +1 -1
- package/lib.commonjs/multipass/Owner.js +34 -16
- package/lib.commonjs/multipass/Owner.js.map +1 -1
- package/lib.commonjs/multipass/Registrar.d.ts +3 -1
- package/lib.commonjs/multipass/Registrar.d.ts.map +1 -1
- package/lib.commonjs/multipass/Registrar.js +2 -2
- package/lib.commonjs/multipass/Registrar.js.map +1 -1
- package/lib.commonjs/rankify/GameMaster.d.ts +5 -1
- package/lib.commonjs/rankify/GameMaster.d.ts.map +1 -1
- package/lib.commonjs/rankify/GameMaster.js.map +1 -1
- package/lib.commonjs/rankify/InstanceAdmininstrative.d.ts +34 -0
- package/lib.commonjs/rankify/InstanceAdmininstrative.d.ts.map +1 -0
- package/lib.commonjs/rankify/InstanceAdmininstrative.js +74 -0
- package/lib.commonjs/rankify/InstanceAdmininstrative.js.map +1 -0
- package/lib.commonjs/rankify/InstanceBase.d.ts +1 -0
- package/lib.commonjs/rankify/InstanceBase.d.ts.map +1 -1
- package/lib.commonjs/rankify/InstanceBase.js +14 -0
- package/lib.commonjs/rankify/InstanceBase.js.map +1 -1
- package/lib.commonjs/rankify/Player.d.ts +2 -36
- package/lib.commonjs/rankify/Player.d.ts.map +1 -1
- package/lib.commonjs/rankify/Player.js +24 -1
- package/lib.commonjs/rankify/Player.js.map +1 -1
- package/lib.commonjs/types.d.ts +33 -0
- package/lib.commonjs/types.d.ts.map +1 -1
- package/lib.commonjs/types.js +7 -1
- package/lib.commonjs/types.js.map +1 -1
- package/lib.commonjs/ubi/InstanceUBI.d.ts +548 -0
- package/lib.commonjs/ubi/InstanceUBI.d.ts.map +1 -0
- package/lib.commonjs/ubi/InstanceUBI.js +728 -0
- package/lib.commonjs/ubi/InstanceUBI.js.map +1 -0
- package/lib.commonjs/utils/EnvioGraphQLClient.d.ts +279 -0
- package/lib.commonjs/utils/EnvioGraphQLClient.d.ts.map +1 -1
- package/lib.commonjs/utils/EnvioGraphQLClient.js +468 -0
- package/lib.commonjs/utils/EnvioGraphQLClient.js.map +1 -1
- package/lib.commonjs/utils/artifacts.d.ts.map +1 -1
- package/lib.commonjs/utils/artifacts.js +15 -3
- package/lib.commonjs/utils/artifacts.js.map +1 -1
- package/lib.commonjs/utils/chainMapping.d.ts.map +1 -1
- package/lib.commonjs/utils/chainMapping.js +0 -1
- package/lib.commonjs/utils/chainMapping.js.map +1 -1
- package/lib.commonjs/utils/mockUtils.d.ts +3 -0
- package/lib.commonjs/utils/mockUtils.d.ts.map +1 -1
- package/lib.commonjs/utils/mockUtils.js +3 -0
- package/lib.commonjs/utils/mockUtils.js.map +1 -1
- package/lib.esm/abis/ArguableVotingTournament.d.ts +8 -0
- package/lib.esm/abis/ArguableVotingTournament.d.ts.map +1 -1
- package/lib.esm/abis/ArguableVotingTournament.js +10 -0
- package/lib.esm/abis/ArguableVotingTournament.js.map +1 -1
- package/lib.esm/abis/MAODistribution.d.ts +12 -0
- package/lib.esm/abis/MAODistribution.d.ts.map +1 -1
- package/lib.esm/abis/MAODistribution.js +16 -0
- package/lib.esm/abis/MAODistribution.js.map +1 -1
- package/lib.esm/abis/MockShortStrings.d.ts +25 -0
- package/lib.esm/abis/MockShortStrings.d.ts.map +1 -0
- package/lib.esm/abis/MockShortStrings.js +34 -0
- package/lib.esm/abis/MockShortStrings.js.map +1 -0
- package/lib.esm/abis/Multipass.d.ts +5 -1
- package/lib.esm/abis/Multipass.d.ts.map +1 -1
- package/lib.esm/abis/Multipass.js +7 -1
- package/lib.esm/abis/Multipass.js.map +1 -1
- package/lib.esm/abis/PausableUpgradeable.d.ts +59 -0
- package/lib.esm/abis/PausableUpgradeable.d.ts.map +1 -0
- package/lib.esm/abis/PausableUpgradeable.js +76 -0
- package/lib.esm/abis/PausableUpgradeable.js.map +1 -0
- package/lib.esm/abis/RankToken.d.ts +30 -0
- package/lib.esm/abis/RankToken.d.ts.map +1 -1
- package/lib.esm/abis/RankToken.js +38 -0
- package/lib.esm/abis/RankToken.js.map +1 -1
- package/lib.esm/abis/RankifyDiamondInstance.d.ts +970 -9
- package/lib.esm/abis/RankifyDiamondInstance.d.ts.map +1 -1
- package/lib.esm/abis/RankifyDiamondInstance.js +1987 -756
- package/lib.esm/abis/RankifyDiamondInstance.js.map +1 -1
- package/lib.esm/abis/RankifyInstanceInit.d.ts +150 -0
- package/lib.esm/abis/RankifyInstanceInit.d.ts.map +1 -1
- package/lib.esm/abis/RankifyInstanceInit.js +190 -0
- package/lib.esm/abis/RankifyInstanceInit.js.map +1 -1
- package/lib.esm/abis/RankifyInstanceMainFacet.d.ts +30 -0
- package/lib.esm/abis/RankifyInstanceMainFacet.d.ts.map +1 -1
- package/lib.esm/abis/RankifyInstanceMainFacet.js +38 -0
- package/lib.esm/abis/RankifyInstanceMainFacet.js.map +1 -1
- package/lib.esm/abis/RankifyOwnersFacet.d.ts +57 -0
- package/lib.esm/abis/RankifyOwnersFacet.d.ts.map +1 -0
- package/lib.esm/abis/RankifyOwnersFacet.js +75 -0
- package/lib.esm/abis/RankifyOwnersFacet.js.map +1 -0
- package/lib.esm/abis/UBI.d.ts +601 -0
- package/lib.esm/abis/UBI.d.ts.map +1 -0
- package/lib.esm/abis/UBI.js +772 -0
- package/lib.esm/abis/UBI.js.map +1 -0
- package/lib.esm/abis/index.d.ts +1935 -1
- package/lib.esm/abis/index.d.ts.map +1 -1
- package/lib.esm/abis/index.js +13 -0
- package/lib.esm/abis/index.js.map +1 -1
- package/lib.esm/abis/superinterface.d.ts +3 -0
- package/lib.esm/abis/superinterface.d.ts.map +1 -0
- package/lib.esm/abis/superinterface.js +3046 -0
- package/lib.esm/abis/superinterface.js.map +1 -0
- package/lib.esm/index.d.ts +2 -0
- package/lib.esm/index.d.ts.map +1 -1
- package/lib.esm/index.js +1 -0
- package/lib.esm/index.js.map +1 -1
- package/lib.esm/multipass/MultipassBase.d.ts +18 -4
- package/lib.esm/multipass/MultipassBase.d.ts.map +1 -1
- package/lib.esm/multipass/MultipassBase.js +40 -72
- package/lib.esm/multipass/MultipassBase.js.map +1 -1
- package/lib.esm/multipass/Owner.d.ts +22 -8
- package/lib.esm/multipass/Owner.d.ts.map +1 -1
- package/lib.esm/multipass/Owner.js +34 -16
- package/lib.esm/multipass/Owner.js.map +1 -1
- package/lib.esm/multipass/Registrar.d.ts +3 -1
- package/lib.esm/multipass/Registrar.d.ts.map +1 -1
- package/lib.esm/multipass/Registrar.js +2 -2
- package/lib.esm/multipass/Registrar.js.map +1 -1
- package/lib.esm/rankify/GameMaster.d.ts +5 -1
- package/lib.esm/rankify/GameMaster.d.ts.map +1 -1
- package/lib.esm/rankify/GameMaster.js.map +1 -1
- package/lib.esm/rankify/InstanceAdmininstrative.d.ts +34 -0
- package/lib.esm/rankify/InstanceAdmininstrative.d.ts.map +1 -0
- package/lib.esm/rankify/InstanceAdmininstrative.js +70 -0
- package/lib.esm/rankify/InstanceAdmininstrative.js.map +1 -0
- package/lib.esm/rankify/InstanceBase.d.ts +1 -0
- package/lib.esm/rankify/InstanceBase.d.ts.map +1 -1
- package/lib.esm/rankify/InstanceBase.js +14 -0
- package/lib.esm/rankify/InstanceBase.js.map +1 -1
- package/lib.esm/rankify/Player.d.ts +2 -36
- package/lib.esm/rankify/Player.d.ts.map +1 -1
- package/lib.esm/rankify/Player.js +24 -1
- package/lib.esm/rankify/Player.js.map +1 -1
- package/lib.esm/types.d.ts +33 -0
- package/lib.esm/types.d.ts.map +1 -1
- package/lib.esm/types.js +6 -0
- package/lib.esm/types.js.map +1 -1
- package/lib.esm/ubi/InstanceUBI.d.ts +548 -0
- package/lib.esm/ubi/InstanceUBI.d.ts.map +1 -0
- package/lib.esm/ubi/InstanceUBI.js +722 -0
- package/lib.esm/ubi/InstanceUBI.js.map +1 -0
- package/lib.esm/utils/EnvioGraphQLClient.d.ts +279 -0
- package/lib.esm/utils/EnvioGraphQLClient.d.ts.map +1 -1
- package/lib.esm/utils/EnvioGraphQLClient.js +468 -0
- package/lib.esm/utils/EnvioGraphQLClient.js.map +1 -1
- package/lib.esm/utils/artifacts.d.ts.map +1 -1
- package/lib.esm/utils/artifacts.js +15 -3
- package/lib.esm/utils/artifacts.js.map +1 -1
- package/lib.esm/utils/chainMapping.d.ts.map +1 -1
- package/lib.esm/utils/chainMapping.js +0 -1
- package/lib.esm/utils/chainMapping.js.map +1 -1
- package/lib.esm/utils/mockUtils.d.ts +3 -0
- package/lib.esm/utils/mockUtils.d.ts.map +1 -1
- package/lib.esm/utils/mockUtils.js +3 -0
- package/lib.esm/utils/mockUtils.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const index_1 = require("../utils/index");
|
|
7
|
+
const abis_1 = __importDefault(require("../abis"));
|
|
8
|
+
const { UBIAbi } = abis_1.default;
|
|
9
|
+
const InstanceBase_1 = __importDefault(require("../rankify/InstanceBase"));
|
|
10
|
+
/**
|
|
11
|
+
* Class for interacting with UBI facet of a Rankify instance
|
|
12
|
+
* Extends InstanceBase and provides UBI-specific functionality
|
|
13
|
+
*/
|
|
14
|
+
class InstanceUBI extends InstanceBase_1.default {
|
|
15
|
+
/** Wallet client for write operations (optional) */
|
|
16
|
+
walletClient;
|
|
17
|
+
/** Account address for write operations */
|
|
18
|
+
account;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new InstanceUBI
|
|
21
|
+
* @param {Object} params - Constructor parameters
|
|
22
|
+
* @param {PublicClient} params.publicClient - Public client for blockchain interactions
|
|
23
|
+
* @param {WalletClient} params.walletClient - Optional wallet client for write operations
|
|
24
|
+
* @param {number} params.chainId - Chain ID of the network
|
|
25
|
+
* @param {Address} params.instanceAddress - Address of the Rankify instance with UBI facet
|
|
26
|
+
* @param {Address} params.account - Optional account address for write operations
|
|
27
|
+
* @param {EnvioGraphQLClient} params.envioClient - Envio GraphQL client for event queries
|
|
28
|
+
*/
|
|
29
|
+
constructor({ publicClient, walletClient, chainId, instanceAddress, account, envioClient, }) {
|
|
30
|
+
super({
|
|
31
|
+
publicClient,
|
|
32
|
+
chainId,
|
|
33
|
+
instanceAddress,
|
|
34
|
+
envioClient,
|
|
35
|
+
});
|
|
36
|
+
this.walletClient = walletClient;
|
|
37
|
+
this.account = account || walletClient?.account?.address;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets the current day number based on block timestamp
|
|
41
|
+
* @returns The current day number (block.timestamp / 1 days)
|
|
42
|
+
*/
|
|
43
|
+
getCurrentDay = async () => {
|
|
44
|
+
try {
|
|
45
|
+
return await this.publicClient.readContract({
|
|
46
|
+
address: this.instanceAddress,
|
|
47
|
+
abi: UBIAbi,
|
|
48
|
+
functionName: "getCurrentDay",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Gets the current day number (alias for getCurrentDay)
|
|
57
|
+
* @returns The current day number
|
|
58
|
+
*/
|
|
59
|
+
currentDay = async () => {
|
|
60
|
+
try {
|
|
61
|
+
return await this.publicClient.readContract({
|
|
62
|
+
address: this.instanceAddress,
|
|
63
|
+
abi: UBIAbi,
|
|
64
|
+
functionName: "currentDay",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Gets the UBI system parameters
|
|
73
|
+
* @returns Object containing dailyClaimAmount, dailySupportAmount, and domainName
|
|
74
|
+
*/
|
|
75
|
+
getUBIParams = async () => {
|
|
76
|
+
try {
|
|
77
|
+
const [dailyClaimAmount, dailySupportAmount, domainName] = await this.publicClient.readContract({
|
|
78
|
+
address: this.instanceAddress,
|
|
79
|
+
abi: UBIAbi,
|
|
80
|
+
functionName: "getUBIParams",
|
|
81
|
+
});
|
|
82
|
+
console.log("dailyClaimAmount", dailyClaimAmount);
|
|
83
|
+
console.log("dailySupportAmount", dailySupportAmount);
|
|
84
|
+
console.log("domainName", domainName);
|
|
85
|
+
return {
|
|
86
|
+
dailyClaimAmount,
|
|
87
|
+
dailySupportAmount,
|
|
88
|
+
domainName,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Gets the lifetime statistics for a proposal
|
|
97
|
+
* @param proposalHash - The hash of the proposal
|
|
98
|
+
* @returns Object containing aggregateScore, proposedTimes, and repostedTimes
|
|
99
|
+
*/
|
|
100
|
+
getProposalLifetimeStats = async (proposalHash) => {
|
|
101
|
+
try {
|
|
102
|
+
const result = await this.publicClient.readContract({
|
|
103
|
+
address: this.instanceAddress,
|
|
104
|
+
abi: UBIAbi,
|
|
105
|
+
functionName: "proposalLifetimeStats",
|
|
106
|
+
args: [proposalHash],
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
aggregateScore: result.aggregateScore,
|
|
110
|
+
proposedTimes: result.proposedTimes,
|
|
111
|
+
repostedTimes: result.repostedTimes,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Gets the daily score for a proposal on a specific day
|
|
120
|
+
* @param proposalHash - The hash of the proposal
|
|
121
|
+
* @param day - The day number to query
|
|
122
|
+
* @returns DailyProposal object with proposal details for that day
|
|
123
|
+
*/
|
|
124
|
+
getProposalDailyScore = async (proposalHash, day) => {
|
|
125
|
+
try {
|
|
126
|
+
const result = await this.publicClient.readContract({
|
|
127
|
+
address: this.instanceAddress,
|
|
128
|
+
abi: UBIAbi,
|
|
129
|
+
functionName: "getProposalDailyScore",
|
|
130
|
+
args: [proposalHash, day],
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
proposal: result.proposal,
|
|
134
|
+
score: result.score,
|
|
135
|
+
proposer: result.proposer,
|
|
136
|
+
exists: result.exists,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Gets the total number of proposals for a specific day
|
|
145
|
+
* @param day - The day number to query
|
|
146
|
+
* @returns The count of proposals for that day
|
|
147
|
+
*/
|
|
148
|
+
getProposalsCnt = async (day) => {
|
|
149
|
+
try {
|
|
150
|
+
return await this.publicClient.readContract({
|
|
151
|
+
address: this.instanceAddress,
|
|
152
|
+
abi: UBIAbi,
|
|
153
|
+
functionName: "getProposalsCnt",
|
|
154
|
+
args: [day],
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
catch (e) {
|
|
158
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Gets the day a user last claimed their tokens
|
|
163
|
+
* @param user - The address of the user
|
|
164
|
+
* @returns The day number of the last claim (0 if never claimed)
|
|
165
|
+
*/
|
|
166
|
+
getLastClaimedAt = async (user) => {
|
|
167
|
+
try {
|
|
168
|
+
return await this.publicClient.readContract({
|
|
169
|
+
address: this.instanceAddress,
|
|
170
|
+
abi: UBIAbi,
|
|
171
|
+
functionName: "lastClaimedAt",
|
|
172
|
+
args: [user],
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
catch (e) {
|
|
176
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Gets the current state for a user
|
|
181
|
+
* @param user - The address of the user
|
|
182
|
+
* @returns Object containing claimedToday and supportSpent
|
|
183
|
+
*/
|
|
184
|
+
getUserState = async (user) => {
|
|
185
|
+
try {
|
|
186
|
+
const [claimedToday, supportSpent] = await this.publicClient.readContract({
|
|
187
|
+
address: this.instanceAddress,
|
|
188
|
+
abi: UBIAbi,
|
|
189
|
+
functionName: "getUserState",
|
|
190
|
+
args: [user],
|
|
191
|
+
});
|
|
192
|
+
return {
|
|
193
|
+
claimedToday,
|
|
194
|
+
supportSpent,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Gets the address of the pauser
|
|
203
|
+
* @returns The address with pausing/unpausing permissions
|
|
204
|
+
*/
|
|
205
|
+
getPauser = async () => {
|
|
206
|
+
try {
|
|
207
|
+
return await this.publicClient.readContract({
|
|
208
|
+
address: this.instanceAddress,
|
|
209
|
+
abi: UBIAbi,
|
|
210
|
+
functionName: "pauser",
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
catch (e) {
|
|
214
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Gets the Multipass contract address
|
|
219
|
+
* @returns The address of the Multipass contract
|
|
220
|
+
*/
|
|
221
|
+
getMultipass = async () => {
|
|
222
|
+
try {
|
|
223
|
+
return await this.publicClient.readContract({
|
|
224
|
+
address: this.instanceAddress,
|
|
225
|
+
abi: UBIAbi,
|
|
226
|
+
functionName: "multipass",
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
catch (e) {
|
|
230
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Gets the governance token contract address
|
|
235
|
+
* @returns The address of the DistributableGovernanceERC20 token
|
|
236
|
+
*/
|
|
237
|
+
getToken = async () => {
|
|
238
|
+
try {
|
|
239
|
+
return await this.publicClient.readContract({
|
|
240
|
+
address: this.instanceAddress,
|
|
241
|
+
abi: UBIAbi,
|
|
242
|
+
functionName: "token",
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
catch (e) {
|
|
246
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Checks if the contract is currently paused
|
|
251
|
+
* @returns True if paused, false otherwise
|
|
252
|
+
*/
|
|
253
|
+
isPaused = async () => {
|
|
254
|
+
try {
|
|
255
|
+
return await this.publicClient.readContract({
|
|
256
|
+
address: this.instanceAddress,
|
|
257
|
+
abi: UBIAbi,
|
|
258
|
+
functionName: "paused",
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
catch (e) {
|
|
262
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Gets comprehensive information about a user's current status
|
|
267
|
+
* @param user - The address of the user
|
|
268
|
+
* @returns Object containing user state, last claimed day, and current day
|
|
269
|
+
*/
|
|
270
|
+
getUserInfo = async (user) => {
|
|
271
|
+
try {
|
|
272
|
+
const [userState, lastClaimedAt, currentDay] = await Promise.all([
|
|
273
|
+
this.getUserState(user),
|
|
274
|
+
this.getLastClaimedAt(user),
|
|
275
|
+
this.getCurrentDay(),
|
|
276
|
+
]);
|
|
277
|
+
return {
|
|
278
|
+
userState,
|
|
279
|
+
lastClaimedAt,
|
|
280
|
+
currentDay,
|
|
281
|
+
canClaim: lastClaimedAt < currentDay,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
catch (e) {
|
|
285
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Gets comprehensive information about a proposal
|
|
290
|
+
* @param proposalHash - The hash of the proposal
|
|
291
|
+
* @param day - Optional day to get daily score (defaults to current day - 1)
|
|
292
|
+
* @returns Object containing lifetime stats and daily score
|
|
293
|
+
*/
|
|
294
|
+
getProposalInfo = async (proposalHash, day) => {
|
|
295
|
+
try {
|
|
296
|
+
const queryDay = day ?? (await this.getCurrentDay()) - 1n;
|
|
297
|
+
const [lifetimeStats, dailyScore] = await Promise.all([
|
|
298
|
+
this.getProposalLifetimeStats(proposalHash),
|
|
299
|
+
this.getProposalDailyScore(proposalHash, queryDay),
|
|
300
|
+
]);
|
|
301
|
+
return {
|
|
302
|
+
lifetimeStats,
|
|
303
|
+
dailyScore,
|
|
304
|
+
day: queryDay,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
catch (e) {
|
|
308
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Gets all proposals for a specific day (requires querying events or off-chain indexer)
|
|
313
|
+
* This is a helper method that would typically use an indexer/subgraph
|
|
314
|
+
* @param day - The day to query
|
|
315
|
+
* @returns The count of proposals for that day
|
|
316
|
+
*/
|
|
317
|
+
getDayProposals = async (day) => {
|
|
318
|
+
try {
|
|
319
|
+
const count = await this.getProposalsCnt(day);
|
|
320
|
+
return {
|
|
321
|
+
count,
|
|
322
|
+
day,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
catch (e) {
|
|
326
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
// ==================== WRITE OPERATIONS ====================
|
|
330
|
+
/**
|
|
331
|
+
* Claims daily UBI tokens and optionally submits a proposal
|
|
332
|
+
* @param proposalText - The proposal text (empty string for no proposal)
|
|
333
|
+
* @returns Transaction hash
|
|
334
|
+
* @throws Error if wallet client is not configured
|
|
335
|
+
*/
|
|
336
|
+
claim = async (proposalText = "") => {
|
|
337
|
+
if (!this.walletClient) {
|
|
338
|
+
throw new Error("Wallet client required for write operations");
|
|
339
|
+
}
|
|
340
|
+
if (!this.account) {
|
|
341
|
+
throw new Error("Account required for write operations");
|
|
342
|
+
}
|
|
343
|
+
try {
|
|
344
|
+
const { request } = await this.publicClient.simulateContract({
|
|
345
|
+
address: this.instanceAddress,
|
|
346
|
+
abi: UBIAbi,
|
|
347
|
+
functionName: "claim",
|
|
348
|
+
args: [proposalText],
|
|
349
|
+
account: this.account,
|
|
350
|
+
});
|
|
351
|
+
const hash = await this.walletClient.writeContract(request);
|
|
352
|
+
return hash;
|
|
353
|
+
}
|
|
354
|
+
catch (e) {
|
|
355
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Supports one or more proposals from the previous day using quadratic voting
|
|
360
|
+
* @param votes - Array of vote elements (proposal hash and amount)
|
|
361
|
+
* @returns Transaction hash
|
|
362
|
+
* @throws Error if wallet client is not configured
|
|
363
|
+
*/
|
|
364
|
+
support = async (votes) => {
|
|
365
|
+
if (!this.walletClient) {
|
|
366
|
+
throw new Error("Wallet client required for write operations");
|
|
367
|
+
}
|
|
368
|
+
if (!this.account) {
|
|
369
|
+
throw new Error("Account required for write operations");
|
|
370
|
+
}
|
|
371
|
+
try {
|
|
372
|
+
const formattedVotes = votes.map((v) => ({
|
|
373
|
+
proposal: v.proposal,
|
|
374
|
+
amount: v.amount,
|
|
375
|
+
}));
|
|
376
|
+
const { request } = await this.publicClient.simulateContract({
|
|
377
|
+
address: this.instanceAddress,
|
|
378
|
+
abi: UBIAbi,
|
|
379
|
+
functionName: "support",
|
|
380
|
+
args: [formattedVotes],
|
|
381
|
+
account: this.account,
|
|
382
|
+
});
|
|
383
|
+
const hash = await this.walletClient.writeContract(request);
|
|
384
|
+
return hash;
|
|
385
|
+
}
|
|
386
|
+
catch (e) {
|
|
387
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Pauses the UBI contract (only callable by pauser)
|
|
392
|
+
* @returns Transaction hash
|
|
393
|
+
* @throws Error if wallet client is not configured or caller is not pauser
|
|
394
|
+
*/
|
|
395
|
+
pause = async () => {
|
|
396
|
+
if (!this.walletClient) {
|
|
397
|
+
throw new Error("Wallet client required for write operations");
|
|
398
|
+
}
|
|
399
|
+
if (!this.account) {
|
|
400
|
+
throw new Error("Account required for write operations");
|
|
401
|
+
}
|
|
402
|
+
try {
|
|
403
|
+
const { request } = await this.publicClient.simulateContract({
|
|
404
|
+
address: this.instanceAddress,
|
|
405
|
+
abi: UBIAbi,
|
|
406
|
+
functionName: "pause",
|
|
407
|
+
account: this.account,
|
|
408
|
+
});
|
|
409
|
+
const hash = await this.walletClient.writeContract(request);
|
|
410
|
+
return hash;
|
|
411
|
+
}
|
|
412
|
+
catch (e) {
|
|
413
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
/**
|
|
417
|
+
* Unpauses the UBI contract (only callable by pauser)
|
|
418
|
+
* @returns Transaction hash
|
|
419
|
+
* @throws Error if wallet client is not configured or caller is not pauser
|
|
420
|
+
*/
|
|
421
|
+
unpause = async () => {
|
|
422
|
+
if (!this.walletClient) {
|
|
423
|
+
throw new Error("Wallet client required for write operations");
|
|
424
|
+
}
|
|
425
|
+
if (!this.account) {
|
|
426
|
+
throw new Error("Account required for write operations");
|
|
427
|
+
}
|
|
428
|
+
try {
|
|
429
|
+
const { request } = await this.publicClient.simulateContract({
|
|
430
|
+
address: this.instanceAddress,
|
|
431
|
+
abi: UBIAbi,
|
|
432
|
+
functionName: "unpause",
|
|
433
|
+
account: this.account,
|
|
434
|
+
});
|
|
435
|
+
const hash = await this.walletClient.writeContract(request);
|
|
436
|
+
return hash;
|
|
437
|
+
}
|
|
438
|
+
catch (e) {
|
|
439
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
// ==================== INDEXER QUERY METHODS ====================
|
|
443
|
+
/**
|
|
444
|
+
* Gets proposals submitted by a specific address
|
|
445
|
+
* @param proposer - Optional address to filter by proposer
|
|
446
|
+
* @param day - Optional day to filter proposals
|
|
447
|
+
* @param limit - Maximum number of results to return
|
|
448
|
+
* @param offset - Number of results to skip
|
|
449
|
+
* @returns Array of proposal events
|
|
450
|
+
*/
|
|
451
|
+
getProposalsByAddress = async ({ proposer, day, limit = 100, offset = 0, } = {}) => {
|
|
452
|
+
try {
|
|
453
|
+
return await this.envioClient.getUBIProposingByAddressEvents({
|
|
454
|
+
instanceAddress: this.instanceAddress,
|
|
455
|
+
proposer,
|
|
456
|
+
day,
|
|
457
|
+
limit,
|
|
458
|
+
offset,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
catch (e) {
|
|
462
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
/**
|
|
466
|
+
* Gets all proposals for a specific day
|
|
467
|
+
* @param day - Optional day to filter proposals (defaults to current day - 1)
|
|
468
|
+
* @param limit - Maximum number of results to return
|
|
469
|
+
* @param offset - Number of results to skip
|
|
470
|
+
* @returns Array of proposal events for the day
|
|
471
|
+
*/
|
|
472
|
+
getDailyProposals = async ({ day, limit = 100, offset = 0, } = {}) => {
|
|
473
|
+
try {
|
|
474
|
+
const queryDay = day ?? (await this.getCurrentDay()) - 1n;
|
|
475
|
+
return await this.envioClient.getUBIProposingByAddressEvents({
|
|
476
|
+
instanceAddress: this.instanceAddress,
|
|
477
|
+
day: queryDay,
|
|
478
|
+
limit,
|
|
479
|
+
offset,
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
catch (e) {
|
|
483
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
/**
|
|
487
|
+
* Gets proposal score updates for a specific proposal
|
|
488
|
+
* @param proposal - Proposal hash to query
|
|
489
|
+
* @param day - Optional day to filter results
|
|
490
|
+
* @param limit - Maximum number of results to return
|
|
491
|
+
* @param offset - Number of results to skip
|
|
492
|
+
* @returns Array of proposal score update events
|
|
493
|
+
*/
|
|
494
|
+
getProposalScoreHistory = async ({ proposal, day, limit = 100, offset = 0, } = {}) => {
|
|
495
|
+
try {
|
|
496
|
+
return await this.envioClient.getUBIProposalScoreUpdatedByProposalEvents({
|
|
497
|
+
instanceAddress: this.instanceAddress,
|
|
498
|
+
proposal,
|
|
499
|
+
day,
|
|
500
|
+
limit,
|
|
501
|
+
offset,
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
catch (e) {
|
|
505
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Gets voting events for a specific participant
|
|
510
|
+
* @param participant - Address to filter by participant
|
|
511
|
+
* @param day - Optional day to filter votes
|
|
512
|
+
* @param limit - Maximum number of results to return
|
|
513
|
+
* @param offset - Number of results to skip
|
|
514
|
+
* @returns Array of voting events
|
|
515
|
+
*/
|
|
516
|
+
getVotesByAddress = async ({ participant, day, limit = 100, offset = 0, } = {}) => {
|
|
517
|
+
try {
|
|
518
|
+
return await this.envioClient.getUBIVotingByAddressEvents({
|
|
519
|
+
instanceAddress: this.instanceAddress,
|
|
520
|
+
participant,
|
|
521
|
+
day,
|
|
522
|
+
limit,
|
|
523
|
+
offset,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
catch (e) {
|
|
527
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
/**
|
|
531
|
+
* Gets all votes for a specific day
|
|
532
|
+
* @param day - Optional day to filter votes (defaults to current day - 1)
|
|
533
|
+
* @param limit - Maximum number of results to return
|
|
534
|
+
* @param offset - Number of results to skip
|
|
535
|
+
* @returns Array of voting events for the day
|
|
536
|
+
*/
|
|
537
|
+
getDailyVotes = async ({ day, limit = 100, offset = 0, } = {}) => {
|
|
538
|
+
try {
|
|
539
|
+
const queryDay = day ?? (await this.getCurrentDay()) - 1n;
|
|
540
|
+
return await this.envioClient.getUBIVotingByAddressEvents({
|
|
541
|
+
instanceAddress: this.instanceAddress,
|
|
542
|
+
day: queryDay,
|
|
543
|
+
limit,
|
|
544
|
+
offset,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
catch (e) {
|
|
548
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
/**
|
|
552
|
+
* Gets claim history
|
|
553
|
+
* @param user - Optional user address to filter claims
|
|
554
|
+
* @param limit - Maximum number of results to return
|
|
555
|
+
* @param offset - Number of results to skip
|
|
556
|
+
* @returns Array of claim events
|
|
557
|
+
*/
|
|
558
|
+
getClaimHistory = async ({ user, limit = 100, offset = 0, } = {}) => {
|
|
559
|
+
try {
|
|
560
|
+
return await this.envioClient.getUBIClaimedEvents({
|
|
561
|
+
instanceAddress: this.instanceAddress,
|
|
562
|
+
user,
|
|
563
|
+
limit,
|
|
564
|
+
offset,
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
catch (e) {
|
|
568
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
/**
|
|
572
|
+
* Gets repost events by reposter
|
|
573
|
+
* @param reposter - Optional address to filter by reposter
|
|
574
|
+
* @param day - Optional day to filter reposts
|
|
575
|
+
* @param limit - Maximum number of results to return
|
|
576
|
+
* @param offset - Number of results to skip
|
|
577
|
+
* @returns Array of repost events
|
|
578
|
+
*/
|
|
579
|
+
getRepostsByAddress = async ({ reposter, day, limit = 100, offset = 0, } = {}) => {
|
|
580
|
+
try {
|
|
581
|
+
return await this.envioClient.getUBIRepostByReposterEvents({
|
|
582
|
+
instanceAddress: this.instanceAddress,
|
|
583
|
+
reposter,
|
|
584
|
+
day,
|
|
585
|
+
limit,
|
|
586
|
+
offset,
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
catch (e) {
|
|
590
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
/**
|
|
594
|
+
* Gets lifetime scores for all proposals
|
|
595
|
+
* @param limit - Maximum number of results to return
|
|
596
|
+
* @param offset - Number of results to skip
|
|
597
|
+
* @returns Array of proposal lifetime score events
|
|
598
|
+
*/
|
|
599
|
+
getProposalLifetimeScores = async ({ limit = 100, offset = 0, } = {}) => {
|
|
600
|
+
try {
|
|
601
|
+
return await this.envioClient.getUBIProposalLifetimeScoreEvents({
|
|
602
|
+
instanceAddress: this.instanceAddress,
|
|
603
|
+
limit,
|
|
604
|
+
offset,
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
catch (e) {
|
|
608
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Gets comprehensive proposal data including proposals, scores, and votes for a specific day
|
|
613
|
+
* @param day - Optional day to query (defaults to current day - 1)
|
|
614
|
+
* @param limit - Maximum number of results per query
|
|
615
|
+
* @returns Object containing proposals, scores, and votes for the day
|
|
616
|
+
*/
|
|
617
|
+
getDayActivity = async ({ day, limit = 100, } = {}) => {
|
|
618
|
+
try {
|
|
619
|
+
const queryDay = day ?? (await this.getCurrentDay()) - 1n;
|
|
620
|
+
const [proposals, votes, reposts] = await Promise.all([
|
|
621
|
+
this.getDailyProposals({ day: queryDay, limit }),
|
|
622
|
+
this.getDailyVotes({ day: queryDay, limit }),
|
|
623
|
+
this.getRepostsByAddress({ day: queryDay, limit }),
|
|
624
|
+
]);
|
|
625
|
+
return {
|
|
626
|
+
day: queryDay,
|
|
627
|
+
proposals,
|
|
628
|
+
votes,
|
|
629
|
+
reposts,
|
|
630
|
+
proposalCount: proposals.length,
|
|
631
|
+
voteCount: votes.length,
|
|
632
|
+
repostCount: reposts.length,
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
catch (e) {
|
|
636
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
/**
|
|
640
|
+
* Gets comprehensive user activity data
|
|
641
|
+
* @param user - User address to query
|
|
642
|
+
* @param limit - Maximum number of results per query
|
|
643
|
+
* @returns Object containing user's proposals, votes, reposts, and claims
|
|
644
|
+
*/
|
|
645
|
+
getUserActivity = async ({ user, limit = 100 }) => {
|
|
646
|
+
try {
|
|
647
|
+
const [proposals, votes, reposts, claims, userInfo] = await Promise.all([
|
|
648
|
+
this.getProposalsByAddress({ proposer: user, limit }),
|
|
649
|
+
this.getVotesByAddress({ participant: user, limit }),
|
|
650
|
+
this.getRepostsByAddress({ reposter: user, limit }),
|
|
651
|
+
this.getClaimHistory({ user, limit }),
|
|
652
|
+
this.getUserInfo(user),
|
|
653
|
+
]);
|
|
654
|
+
return {
|
|
655
|
+
user,
|
|
656
|
+
userInfo,
|
|
657
|
+
proposals,
|
|
658
|
+
votes,
|
|
659
|
+
reposts,
|
|
660
|
+
claims,
|
|
661
|
+
proposalCount: proposals.length,
|
|
662
|
+
voteCount: votes.length,
|
|
663
|
+
repostCount: reposts.length,
|
|
664
|
+
claimCount: claims.length,
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
catch (e) {
|
|
668
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
/**
|
|
672
|
+
* Gets aggregated proposal scores from voting events
|
|
673
|
+
* @param day - Optional day to filter votes
|
|
674
|
+
* @param limit - Maximum number of voting events to fetch
|
|
675
|
+
* @returns Map of proposal hashes to their total support scores
|
|
676
|
+
*/
|
|
677
|
+
getProposalScores = async ({ day, limit = 1000, } = {}) => {
|
|
678
|
+
try {
|
|
679
|
+
const votes = await this.getVotesByAddress({
|
|
680
|
+
day,
|
|
681
|
+
limit,
|
|
682
|
+
});
|
|
683
|
+
// Aggregate votes by proposal
|
|
684
|
+
const proposalScores = new Map();
|
|
685
|
+
votes.forEach((vote) => {
|
|
686
|
+
// Each vote event has proposal and amount directly
|
|
687
|
+
const proposalHash = vote.proposal;
|
|
688
|
+
const amount = vote.amount || BigInt(0);
|
|
689
|
+
const currentScore = proposalScores.get(proposalHash) || BigInt(0);
|
|
690
|
+
proposalScores.set(proposalHash, currentScore + amount);
|
|
691
|
+
});
|
|
692
|
+
// Convert to array and sort by score
|
|
693
|
+
const sortedScores = Array.from(proposalScores.entries())
|
|
694
|
+
.map(([proposal, score]) => ({
|
|
695
|
+
proposal,
|
|
696
|
+
score,
|
|
697
|
+
stars: Math.floor(Number(score)), // Direct token count as stars
|
|
698
|
+
}))
|
|
699
|
+
.sort((a, b) => Number(b.score - a.score));
|
|
700
|
+
return sortedScores;
|
|
701
|
+
}
|
|
702
|
+
catch (e) {
|
|
703
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
/**
|
|
707
|
+
* Gets the score for a specific proposal
|
|
708
|
+
* @param proposalHash - The hash of the proposal
|
|
709
|
+
* @param day - Optional day to filter votes
|
|
710
|
+
* @returns Total support score for the proposal
|
|
711
|
+
*/
|
|
712
|
+
getProposalScore = async (proposalHash, day) => {
|
|
713
|
+
try {
|
|
714
|
+
const scores = await this.getProposalScores({ day });
|
|
715
|
+
const proposalScore = scores.find((s) => s.proposal === proposalHash);
|
|
716
|
+
return {
|
|
717
|
+
proposal: proposalHash,
|
|
718
|
+
score: proposalScore?.score || BigInt(0),
|
|
719
|
+
stars: proposalScore?.stars || 0,
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
catch (e) {
|
|
723
|
+
throw await (0, index_1.handleRPCError)(e);
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
exports.default = InstanceUBI;
|
|
728
|
+
//# sourceMappingURL=InstanceUBI.js.map
|