Skip to content

Commit

Permalink
Merge pull request #23 from aboutcircles/feature/rc-v0.3.5-contracts
Browse files Browse the repository at this point in the history
0.7.0-preview-1
  • Loading branch information
jaensen authored Aug 14, 2024
2 parents 3c0156f + 04b20ab commit 74bf969
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 53 deletions.
2 changes: 1 addition & 1 deletion contract-artifacts/v2/Hub.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contract-artifacts/v2/Migration.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contract-artifacts/v2/NameRegistry.json

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
},
"name": "@cirlces-sdk/root",
"license": "MIT",
"version": "0.6.0-preview-1"
"version": "0.7.0-preview-1"
}
2 changes: 1 addition & 1 deletion packages/abi-v1/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circles-sdk/abi-v1",
"version": "0.6.0-preview-1",
"version": "0.7.0-preview-1",
"description": "",
"type": "module",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/abi-v2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circles-sdk/abi-v2",
"version": "0.6.0-preview-1",
"version": "0.7.0-preview-1",
"description": "",
"type": "module",
"main": "./dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-cometh/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circles-sdk/adapter-cometh",
"version": "0.6.0-preview-1",
"version": "0.7.0-preview-1",
"description": "",
"type": "module",
"main": "./dist/index.js",
Expand All @@ -17,7 +17,7 @@
"build": "rollup -c"
},
"dependencies": {
"@circles-sdk/adapter": "0.6.0-preview-1",
"@circles-sdk/adapter": "0.7.0-preview-1",
"@cometh/connect-sdk": "1.2.29"
},
"keywords": [],
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circles-sdk/adapter-ethers",
"version": "0.6.0-preview-1",
"version": "0.7.0-preview-1",
"description": "",
"type": "module",
"main": "./dist/index.js",
Expand All @@ -18,7 +18,7 @@
},
"dependencies": {
"ethers": "^6.13.2",
"@circles-sdk/adapter": "0.6.0-preview-1"
"@circles-sdk/adapter": "0.7.0-preview-1"
},
"keywords": [],
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circles-sdk/adapter",
"version": "0.6.0-preview-1",
"version": "0.7.0-preview-1",
"description": "",
"type": "module",
"main": "./dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circles-sdk/data",
"version": "0.6.0-preview-1",
"version": "0.7.0-preview-1",
"description": "",
"type": "module",
"main": "./dist/index.js",
Expand All @@ -17,7 +17,7 @@
"build": "rollup -c"
},
"dependencies": {
"@circles-sdk/utils": "0.6.0-preview-1"
"@circles-sdk/utils": "0.7.0-preview-1"
},
"keywords": [],
"author": "",
Expand Down
4 changes: 2 additions & 2 deletions packages/profiles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circles-sdk/profiles",
"version": "0.6.0-preview-1",
"version": "0.7.0-preview-1",
"description": "",
"type": "module",
"main": "./dist/index.js",
Expand All @@ -17,7 +17,7 @@
"build": "rollup -c"
},
"dependencies": {
"@circles-sdk/utils": "0.6.0-preview-1"
"@circles-sdk/utils": "0.7.0-preview-1"
},
"keywords": [],
"author": "",
Expand Down
12 changes: 6 additions & 6 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circles-sdk/sdk",
"version": "0.6.0-preview-1",
"version": "0.7.0-preview-1",
"description": "",
"type": "module",
"main": "./dist/index.js",
Expand All @@ -17,11 +17,11 @@
"author": "",
"license": "MIT",
"dependencies": {
"@circles-sdk/abi-v1": "0.6.0-preview-1",
"@circles-sdk/abi-v2": "0.6.0-preview-1",
"@circles-sdk/data": "0.6.0-preview-1",
"@circles-sdk/profiles": "0.6.0-preview-1",
"@circles-sdk/adapter-ethers": "0.6.0-preview-1",
"@circles-sdk/abi-v1": "0.7.0-preview-1",
"@circles-sdk/abi-v2": "0.7.0-preview-1",
"@circles-sdk/data": "0.7.0-preview-1",
"@circles-sdk/profiles": "0.7.0-preview-1",
"@circles-sdk/adapter-ethers": "0.7.0-preview-1",
"ethers": "^6.13.2",
"multihashes": "^4.0.3"
},
Expand Down
10 changes: 10 additions & 0 deletions packages/sdk/src/v2/v2Avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ export class V2Avatar implements AvatarInterfaceV2 {

async transfer(to: string, amount: bigint, tokenAddress?: string): Promise<ContractTransactionReceipt> {
if (!tokenAddress) {
const approvalStatus = await this.sdk.v2Hub!.isApprovedForAll(this.address, this.address);
if (!approvalStatus) {
const tx = await this.sdk.v2Hub!.setApprovalForAll(this.address, true);
const receipt = await tx.wait();
if (!receipt) {
throw new Error('Approval failed');
}
}
console.log(`Approval by ${this.address} for ${this.address} successful`);

return this.transitiveTransfer(to, amount);
} else {
return this.directTransfer(to, amount, tokenAddress);
Expand Down
20 changes: 10 additions & 10 deletions packages/tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/tests/test/sdk/v1/v1Avatar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { parseError } from '@circles-sdk/sdk';

describe('error decoder', () => {
it('should decode error codes', async () => {
const error = '0xde84eec90000000000000000000000002dadafd4dcb8ac187a90e04eeadf614de69dee73000000000000000000000000d68193591d47740e51dfbc410da607a351b565860000000000000000000000000000000000000000000000000000000000000001';
const error = '0x39bbf042000000000000000000000000ed31ba919d6b836a6efe3f8225f6f79e71fb3b38000000000000000000000000ed31ba919d6b836a6efe3f8225f6f79e71fb3b3800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
const decoded = parseError(error);
console.log(decoded);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circles-sdk/utils",
"version": "0.6.0-preview-1",
"version": "0.7.0-preview-1",
"description": "",
"type": "module",
"main": "./dist/index.js",
Expand Down
11 changes: 11 additions & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,15 @@ export function addressToUInt256(address: string): bigint {

// Convert the address to a BigInt
return BigInt('0x' + address);
}

export function uint256ToAddress(uint256: bigint): string {
// Convert the BigInt to a hex string
let hexString = uint256.toString(16);

// Add leading zeros to ensure the string length is 40
hexString = hexString.padStart(40, '0');

// Add the '0x' prefix
return '0x' + hexString;
}

0 comments on commit 74bf969

Please sign in to comment.