Comments (5)
@davidyuk Thank you for your answer. I will upgrade the contract to FATE V3. Then there will be no problem
from aepp-sdk-js.
@davidyuk should know !
from aepp-sdk-js.
AENS.transfer
still works, but signature format changed since Ceres.
As far as we all in Ceres the best to use signDelegation
method of Account or AeSdk.
The error you have is because aepp-calldata expects to get signature as hex string or Buffer, but sdk encodes it as sg_
. So, you need to decode
signature before passing to calldata. Related issue: aeternity/aepp-calldata-js#240
Here is example of changing name owner via delegation signature in Ceres using the [email protected]
import {
Node, AeSdk, MemoryAccount, CompilerHttp, DelegationTag, packDelegation, decode,
} from '@aeternity/aepp-sdk';
const [owner, recipient] = [MemoryAccount.generate(), MemoryAccount.generate()];
console.log('Owner address', owner.address);
console.log('Recipient address', recipient.address);
const aeSdk = new AeSdk({
accounts: [owner],
nodes: [{ name: 'testnet', instance: new Node('https://testnet.aeternity.io') }],
onCompiler: new CompilerHttp('https://v7.compiler.aepps.com'),
});
await fetch(`https://faucet.aepps.com/account/${owner.address}`, { method: 'POST' });
const name = `test-name-${Date.now()}.chain`;
await aeSdk.aensClaim(name, 0);
console.log('Claimed name', name);
console.log('Name owner', (await aeSdk.aensQuery(name)).owner);
const contractSourceCode = `
contract DelegateTest =
stateful entrypoint transfer(
owner: address, new_owner: address, name: string, sign: signature): unit =
AENS.transfer(owner, new_owner, name, signature = sign)
`;
const contract = await aeSdk.initializeContract({ sourceCode: contractSourceCode });
const contractAddress = (await contract.$deploy([])).address;
console.log('Contract deployed at', contractAddress);
const delegation = packDelegation({
tag: DelegationTag.AensName, accountAddress: aeSdk.address, contractAddress, nameId: name,
});
const delegationSignature = decode(await aeSdk.signDelegation(delegation));
await contract.transfer(owner.address, recipient.address, name, delegationSignature);
console.log('Name transferred');
console.log('Name owner', (await aeSdk.aensQuery(name)).owner);
from aepp-sdk-js.
I tried to use the method you provided to call, but still failed
Is there something wrong? I did not find it....
![image](https://private-user-images.githubusercontent.com/8652427/331014504-a5b90d80-f5d8-487c-9606-29cb3387339d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk0MDM4NDUsIm5iZiI6MTcxOTQwMzU0NSwicGF0aCI6Ii84NjUyNDI3LzMzMTAxNDUwNC1hNWI5MGQ4MC1mNWQ4LTQ4N2MtOTYwNi0yOWNiMzM4NzMzOWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjZUMTIwNTQ1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTc3MDQwOWE5MzQzNmU0MmFmZTUwMjFiOTQ0NTIyMDgwMGZjYjA4NjRlYmI1MGE2NjFjMDJiZGQ5ODQzNDE4ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.GLj2Cg45x7xV60bLCJAxmDloeq1dVsmTUuxgjeCeqL0)
from aepp-sdk-js.
A private key exposed in the above message, ensure that you don't have much funds there!
I figured out the issue. Contracts deployed in Iris are executed in FATE v2, so it expects an old signature format. The problem is that we have security concerns about that format, and I would like to drop its support in future SDK versions. Is it feasible to migrate your contracts to FATE v3?
Meanwhile, you can provide consensusProtocolVersion: ConsensusProtocolVersion.Iris
option to generate an old signature in Ceres using AeSdk::signNameDelegationToContract
. See the below reproduction.
The code I've used to test it
import {
Node, AeSdk, MemoryAccount, CompilerHttp, ConsensusProtocolVersion, decode,
} from '@aeternity/aepp-sdk';
const [owner, recipient] = [
new MemoryAccount('9ebd7beda0c79af72a42ece3821a56eff16359b6df376cf049aee995565f022f840c974b97164776454ba119d84edc4d6058a8dec92b6edc578ab2d30b4c4200'),
MemoryAccount.generate(),
];
console.log('Owner address', owner.address);
console.log('Recipient address', recipient.address);
const aeSdk = new AeSdk({
accounts: [owner],
nodes: [{ name: 'testnet', instance: new Node('http://localhost:3013') }],
onCompiler: new CompilerHttp('https://v7.compiler.aepps.com'),
});
const contractSourceCode = `
contract DelegateTest =
stateful entrypoint transfer(
owner: address, new_owner: address, name: string, sign: signature): unit =
AENS.transfer(owner, new_owner, name, signature = sign)
`;
const contract = await aeSdk.initializeContract({ sourceCode: contractSourceCode });
const contractAddress = (await contract.$deploy([])).address;
console.log('Contract deployed at', contractAddress);
console.log('Height', await aeSdk.getHeight());
console.log('Consensus', ConsensusProtocolVersion[(await aeSdk.api.getNodeInfo()).consensusProtocolVersion]);
const name = `test-name-${Date.now()}.chain`;
const nameObj = await aeSdk.aensPreclaim(name);
await nameObj.claim();
console.log('Claimed name', name);
console.log('Name owner', (await aeSdk.aensQuery(name)).owner);
console.log('Height', await aeSdk.getHeight());
console.log('Consensus', ConsensusProtocolVersion[(await aeSdk.api.getNodeInfo()).consensusProtocolVersion]);
const delegationSignature = await aeSdk.signNameDelegationToContract(
contractAddress,
name,
{ consensusProtocolVersion: ConsensusProtocolVersion.Iris },
);
console.log('delegationSignature', delegationSignature);
const delegationSignatureAsHex = decode(delegationSignature);
await contract.transfer(owner.address, recipient.address, name, delegationSignatureAsHex);
console.log('Name transferred');
console.log('Name owner', (await aeSdk.aensQuery(name)).owner);
dev_mode:
auto_emit_microblocks: true
chain:
persist: false
hard_forks:
"1": 0
"5": 1
"6": 2
genesis_accounts:
ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E: 10000000000000000000000
So, the contract deployed in Iris and called in Ceres.
from aepp-sdk-js.
Related Issues (20)
- Adapt tests to run on testnet (ae_uat) HOT 1
- The decoded value type shouldn't change depending on its magnitude in state channels
- Ensure target exist before calling reflect for better error message
- `npm run build:api` takes significant (infinite?) time on Apple M* HOT 2
- Require node@18 and above
- Update node, compiler, middleware swagger files HOT 1
- Need documentation for message signing/verifying HOT 1
- Avoid using `instanceof` to be compatible with Jest
- Create tx price estimation function HOT 3
- Ensure compatible with LavaMoat used in MetaMask
- Reverse iframe is not working if aepp and wallet on separate domain because of storage partitioning
- Accept logger object in sdk methods
- A way to show the last connected wallet details without an active connection (e.g. after page reload)
- Accept/return AENS pointer keys as binary to don't limit the protocol
- Consider aepp to trigger disconnect on`beforeunload` in iframe flow
- Aepp-wallet connection via aeternity snap for Metamask
- Some keys not converted to camelCase
- `limit` parameter missed in `_Middleware:getTxs`
- Total supply for some tokens is incorrect HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aepp-sdk-js.