Skip to content

Commit

Permalink
refactor(wallet,aepp)!: remove delegationToContract.sign method
Browse files Browse the repository at this point in the history
BREAKING CHANGE: delegations used in Iris removed from aepp-wallet connection
Use `signDelegation` api instead.
  • Loading branch information
davidyuk committed Jun 8, 2024
1 parent c1af77c commit c4d62b0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 59 deletions.
21 changes: 0 additions & 21 deletions src/AeSdkWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,27 +303,6 @@ export default class AeSdkWallet extends AeSdk {
signature: await this.signTypedData(data, aci, parameters),
};
},
[METHODS.signDelegationToContract]: async ({
contractAddress, name, oracleQueryId, allNames, onAccount = this.address, isOracle,
}, origin) => {
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
if (!this.addresses().includes(onAccount)) {
throw new RpcPermissionDenyError(onAccount);
}

isOracle ??= false;
const parameters = { onAccount, aeppOrigin: origin, aeppRpcClientId: id };
const signature = await (
(name == null ? null : this
.signNameDelegationToContract(contractAddress, name, parameters))
?? (oracleQueryId == null ? null : this
.signOracleQueryDelegationToContract(contractAddress, oracleQueryId, parameters))
?? (allNames !== true ? null : this
.signAllNamesDelegationToContract(contractAddress, parameters))
?? this.signDelegationToContract(contractAddress, { ...parameters, isOracle })
);
return { signature };
},
[METHODS.unsafeSign]: async ({ data, onAccount = this.address }, origin) => {
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
if (!this.addresses().includes(onAccount)) throw new RpcPermissionDenyError(onAccount);
Expand Down
30 changes: 5 additions & 25 deletions src/account/Rpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AccountBase from './Base';
import { METHODS } from '../aepp-wallet-communication/schema';
import { ArgumentError, UnsupportedProtocolError } from '../utils/errors';
import { ArgumentError, NotImplementedError, UnsupportedProtocolError } from '../utils/errors';
import {
Encoded, Encoding, decode, encode,
} from '../utils/encoder';
Expand Down Expand Up @@ -96,12 +96,7 @@ export default class AccountRpc extends AccountBase {
});
return this.signDelegation(delegation);
}
const { signature } = await this._rpcClient.request(METHODS.signDelegationToContract, {
onAccount: this.address,
contractAddress,
isOracle,
});
return signature;
throw new NotImplementedError('');
}

override async signNameDelegationToContract(
Expand All @@ -115,12 +110,7 @@ export default class AccountRpc extends AccountBase {
});
return this.signDelegation(delegation);
}
const { signature } = await this._rpcClient.request(METHODS.signDelegationToContract, {
onAccount: this.address,
contractAddress,
name,
});
return signature;
throw new NotImplementedError('');
}

override async signAllNamesDelegationToContract(
Expand All @@ -133,12 +123,7 @@ export default class AccountRpc extends AccountBase {
});
return this.signDelegation(delegation);
}
const { signature } = await this._rpcClient.request(METHODS.signDelegationToContract, {
onAccount: this.address,
contractAddress,
allNames: true,
});
return signature;
throw new NotImplementedError('');
}

override async signOracleQueryDelegationToContract(
Expand All @@ -152,12 +137,7 @@ export default class AccountRpc extends AccountBase {
});
return this.signDelegation(delegation);
}
const { signature } = await this._rpcClient.request(METHODS.signDelegationToContract, {
onAccount: this.address,
contractAddress,
oracleQueryId,
});
return signature;
throw new NotImplementedError('');
}

override async signDelegation(delegation: Encoded.Bytearray): Promise<Encoded.Signature> {
Expand Down
12 changes: 0 additions & 12 deletions src/aepp-wallet-communication/rpc/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Domain, AciValue } from '../../utils/typed-data';
import { METHODS, SUBSCRIPTION_TYPES, WALLET_TYPE } from '../schema';
import { TransformNodeType } from '../../Node';
import { SignedTx } from '../../apis/node';
import { AensName } from '../../tx/builder/constants';

export interface WalletInfo {
id: string;
Expand Down Expand Up @@ -88,17 +87,6 @@ export interface WalletApi {
},
) => Promise<{ signature: Encoded.Signature }>;

[METHODS.signDelegationToContract]: (
p: {
contractAddress: Encoded.ContractAddress;
name?: AensName;
oracleQueryId?: Encoded.OracleQueryId;
allNames?: boolean;
isOracle?: boolean;
onAccount: Encoded.AccountAddress;
},
) => Promise<{ signature: Encoded.Signature }>;

[METHODS.signDelegation]: (
p: {
delegation: Encoded.Bytearray;
Expand Down
1 change: 0 additions & 1 deletion src/aepp-wallet-communication/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const enum METHODS {
sign = 'transaction.sign',
signMessage = 'message.sign',
signTypedData = 'typedData.sign',
signDelegationToContract = 'delegationToContract.sign',
signDelegation = 'delegation.sign',
subscribeAddress = 'address.subscribe',
updateNetwork = 'networkId.update',
Expand Down

0 comments on commit c4d62b0

Please sign in to comment.