add Weighted Threshold
Adds a weighted threshold policy to a context rule.
A weighted threshold policy assigns different weights (vote power) to each signer. The sum of weights from approving signers must meet or exceed the threshold.
Encodes the signer weights and threshold parameters and delegates to addPolicy.
IMPORTANT: This operation requires the connected wallet to have authorization on the smart account. The user will be prompted for biometric authentication to sign the transaction.
Contract limits:
Maximum OZConstants.MAX_POLICIES policies per context rule
Policy address must be a valid C-address
At least one signer weight must be specified
Threshold must be greater than zero
Return
TransactionResult indicating success or failure
Parameters
The context rule ID to add the policy to (0 for Default rule)
The policy contract address (C-address)
Map of signers to their weights defining vote power
Minimum total weight required for authorization
Optional list of signers for multi-signer authorization. When empty (default), uses single-signer auth with the connected passkey. When non-empty, coordinates signatures from all listed signers.
Optional submission method override. When null (default), uses the configured submission method (relayer if available, RPC otherwise).
Throws
if validation fails
if transaction submission fails
Example:
// Create a weighted threshold policy (100 points required)
val result = policyManager.addWeightedThreshold(
contextRuleId = 0u,
policyAddress = "CBCD1234...",
signerWeights = mapOf(
delegatedSigner1 to 50u,
delegatedSigner2 to 30u,
externalSigner to 20u
),
threshold = 100u
)
if (result.success) {
println("Weighted policy added: ${result.hash ?: ""}")
} else {
println("Failed to add policy: ${result.error ?: ""}")
}