Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/auth-ff-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Auth and Fast-Forward
on:
pull_request:
types: [opened, reopened, synchronize]
issue_comment:
types: [created]

jobs:
auth-and-merge:
if: >
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' &&
contains(github.event.comment.body, '/fast-forward') &&
github.event.issue.pull_request)
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# For PR events: checks out the PR merge commit
# For comment events: fetches PR head using the PR number
ref: ${{ github.event.pull_request.head.sha || format('refs/pull/{0}/head', github.event.issue.number) }}
- name: Polymesh Action - Auth and Fast-Forward
uses: PolymeshAssociation/polymesh-action-public@v1.1.4
with:
allowed-signers: ${{ vars.MIDDLEWARE_ALLOWED_SIGNERS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-mode: 'always'
auth-required: 'true'
required-key-type: 'ed25519-sk'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@polkadot/util": "12.6.2",
"@polkadot/util-crypto": "12.6.2",
"@polymeshassociation/browser-extension-signing-manager": "^2.3.0",
"@polymeshassociation/polymesh-sdk": "^29.1.0-beta.7",
"@polymeshassociation/polymesh-sdk": "^29.1.0-beta.10",
"@polymeshassociation/walletconnect-signing-manager": "^1.0.0",
"@tanstack/react-table": "^8.20.5",
"@types/lodash": "^4.17.15",
Expand Down
42 changes: 42 additions & 0 deletions src/hooks/polymesh/useAssetActions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { BigNumber } from '@polymeshassociation/polymesh-sdk';
import type {
AddBalanceStatParams,
AddClaimBalanceStatParams,
AddClaimCountStatParams,
AddCountStatParams,
InputCondition,
NftMetadataInput,
Requirement,
Expand Down Expand Up @@ -1016,6 +1020,43 @@ const useAssetActions = (
}
};

const setTransferRestrictionStats = async ({
stats,
onTransactionRunning,
}: {
stats: (
| AddCountStatParams
| AddBalanceStatParams
| AddClaimCountStatParams
| AddClaimBalanceStatParams
)[];
onTransactionRunning?: () => void | Promise<void>;
}) => {
if (!asset) {
notifyError('Asset not available');
return;
}

// Type narrow: only FungibleAsset supports transfer restrictions
if (!('issuance' in asset)) {
notifyError(
'Transfer restriction statistics are only supported for fungible assets, not NFT collections',
);
return;
}

try {
const fungibleAsset = asset as FungibleAsset;
await executeTransaction(
fungibleAsset.transferRestrictions.setStats({ stats }),
createOptions(onTransactionRunning),
);
} catch (error) {
// Error is already handled by the transaction context and notified to the user
// This catch block prevents unhandled promise rejection
}
};

return {
issueTokens,
redeemTokens,
Expand Down Expand Up @@ -1055,6 +1096,7 @@ const useAssetActions = (
addComplianceRule,
modifyComplianceRule,
removeComplianceRule,
setTransferRestrictionStats,
transactionInProcess,
};
};
Expand Down
Loading