Skip to content

dispatchDelegateAuthorization

dispatchDelegateAuthorization(request, authorAccount, authorizationUri, signCallback): Promise<AuthorizationId>

Dispatches a delegate authorization transaction to the CORD blockchain.

Parameters

request: ISpaceAuthorization

The space authorization request containing necessary information for dispatching the authorization.

authorAccount: CordKeyringPair

The blockchain account used to sign and submit the transaction.

authorizationUri: auth:cord:${string}

The URI of the authorization used for delegating permissions.

signCallback: SignExtrinsicCallback

A callback function that handles the signing of the transaction.

Returns

Promise<AuthorizationId>

A promise resolving to the authorization ID after successful processing by the blockchain.

Remarks

This function manages the process of submitting a delegate authorization request to the blockchain. It checks if the specified authorization already exists. If it does not, the function constructs and submits a transaction to authorize a delegate for a specific space. The transaction is authorized by the delegator’s DID and signed using the provided blockchain account.

Example

const request: ISpaceAuthorization = {
uri: 'space:example_uri',
delegateUri: 'did:example:delegateUri',
permission: PermissionType.EXAMPLE_PERMISSION,
authorizationUri: 'auth:example_uri',
delegatorUri: 'did:example:creatorUri'
};
const authorAccount: CordKeyringPair = { ... };
const authorizationUri: AuthorizationUri = 'auth:example_uri';
const signCallback: SignExtrinsicCallback = (tx) => { ... };
dispatchDelegateAuthorization(request, authorAccount, authorizationUri, signCallback)
.then(authorizationId => {
console.log('Authorization dispatched with ID:', authorizationId);
})
.catch(error => {
console.error('Error dispatching authorization:', error);
});

Throws

  • Thrown on error during the dispatch process.

Source

chain-space/src/ChainSpace.chain.ts:512