Compare commits

..
Author SHA1 Message Date
github-actions[bot]andgithub-actions[bot] 96d2dfd25d Version Packages (#467)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-01-03 14:54:29 +13:00
Yash 5862c558fb [SDK] Update forwarder address (#469) 2022-12-20 12:42:02 -08:00
Adam MajmudarandJoaquim Verges e913e0daa9 [SDK] Add SDK options to factory (#465)
Co-authored-by: Joaquim Verges <[email protected]>
2022-12-17 13:05:52 +13:00
Joaquim Verges f7a74a3b7c [SDK] Expose sdk.wallet.signTypedData() (#468) 2022-12-16 23:50:36 +00:00
Joaquim Verges 73883f56d0 [SDK] workaround for signing typed data with magic.link signers (#466) 2022-12-17 10:44:03 +13:00
Jonas Daniels e47085af92 [config] add timeouts for all relevant github actions (#464) 2022-12-16 10:06:58 +01:00
23 changed files with 137 additions and 40 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ concurrency:
jobs:
build:
name: Build and Test
# timeout-minutes: 15
timeout-minutes: 30
runs-on: ubuntu-latest-32
# To use Remote Caching, uncomment the next lines and follow the steps below.
env:
+1 -1
View File
@@ -12,7 +12,7 @@ concurrency:
jobs:
integration-tests:
timeout-minutes: 60
timeout-minutes: 30
runs-on: ubuntu-latest-32
steps:
- uses: actions/checkout@v3
+1 -2
View File
@@ -13,8 +13,7 @@ concurrency:
jobs:
lint:
name: Lint
# timeout-minutes: 15
# try out buildjet to speed up build and test
timeout-minutes: 15
runs-on: ubuntu-latest
# To use Remote Caching, uncomment the next lines and follow the steps below.
env:
+1
View File
@@ -41,6 +41,7 @@ jobs:
deploy:
runs-on: ubuntu-latest-32
timeout-minutes: 30
needs: deploy-check
if: needs.deploy-check.outputs.triggered == 'true'
steps:
+1
View File
@@ -14,6 +14,7 @@ concurrency:
jobs:
release:
name: Release
timeout-minutes: 30
runs-on: ubuntu-latest-32
steps:
- name: Checkout branch
+1
View File
@@ -5,6 +5,7 @@ on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest-32
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
+2
View File
@@ -1,5 +1,7 @@
# @thirdweb-dev/auth
## 2.0.39
## 2.0.38
## 2.0.37
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "2.0.38",
"version": "2.0.39",
"exports": {
"./next": {
"module": "./next/dist/thirdweb-dev-auth-next.esm.js",
+7
View File
@@ -1,5 +1,12 @@
# thirdweb
## 0.9.8
### Patch Changes
- Updated dependencies [[`e913e0d`](https://github.com/thirdweb-dev/js/commit/e913e0daa9ece9a6274f7ffa4e66bdcbf32e6ada), [`5862c55`](https://github.com/thirdweb-dev/js/commit/5862c558fb48604b5aca4defd1ccc06fc3536358), [`73883f5`](https://github.com/thirdweb-dev/js/commit/73883f56d0ed0a35ace8b98b96caa782443be22e), [`f7a74a3`](https://github.com/thirdweb-dev/js/commit/f7a74a3b7c489ada5b1ec435632a326334a33c9b)]:
- @thirdweb-dev/sdk@3.6.9
## 0.9.7
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.9.7",
"version": "0.9.8",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+2
View File
@@ -1,5 +1,7 @@
# @thirdweb-dev/react
## 3.6.9
## 3.6.8
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "3.6.8",
"version": "3.6.9",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
File diff suppressed because one or more lines are too long
+12
View File
@@ -1,5 +1,17 @@
# @thirdweb-dev/sdk
## 3.6.9
### Patch Changes
- [#465](https://github.com/thirdweb-dev/js/pull/465) [`e913e0d`](https://github.com/thirdweb-dev/js/commit/e913e0daa9ece9a6274f7ffa4e66bdcbf32e6ada) Thanks [@adam-maj](https://github.com/adam-maj)! - Fix passing options to factory
- [`5862c55`](https://github.com/thirdweb-dev/js/commit/5862c558fb48604b5aca4defd1ccc06fc3536358) Thanks [@kumaryash90](https://github.com/kumaryash90)! - update forwarder address
- [#466](https://github.com/thirdweb-dev/js/pull/466) [`73883f5`](https://github.com/thirdweb-dev/js/commit/73883f56d0ed0a35ace8b98b96caa782443be22e) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - workaround for signing typed data with magic.link signers
- [#468](https://github.com/thirdweb-dev/js/pull/468) [`f7a74a3`](https://github.com/thirdweb-dev/js/commit/f7a74a3b7c489ada5b1ec435632a326334a33c9b) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Expose `sdk.wallet.signTypedData()`
## 3.6.8
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/sdk",
"version": "3.6.8",
"version": "3.6.9",
"description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0",
+11 -2
View File
@@ -49,6 +49,7 @@ export async function signTypedDataInternal(
);
let signature = "";
const signerAddress = (await signer.getAddress()).toLowerCase();
// an indirect way for accessing walletconnect's underlying provider
if ((provider as any)?.provider?.isWalletConnect) {
@@ -66,11 +67,19 @@ export async function signTypedDataInternal(
} catch (err: any) {
if (err?.message?.includes("Method eth_signTypedData_v4 not supported")) {
signature = await provider.send("eth_signTypedData", [
(await signer.getAddress()).toLowerCase(),
signerAddress,
JSON.stringify(payload),
]);
} else {
throw err;
// magic.link signer only supports this way
try {
await provider.send("eth_signTypedData_v4", [
signerAddress,
JSON.stringify(payload),
]);
} catch (finalErr: any) {
throw finalErr;
}
}
}
}
+2 -2
View File
@@ -92,7 +92,7 @@ export const CONTRACT_ADDRESSES: Record<
twBYOCRegistry: "0x3E6eE864f850F5e5A98bc950B68E181Cf4010F23",
},
[ChainId.Arbitrum]: {
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
openzeppelinForwarder: "0x8cbc8B5d71702032904750A66AEfE8B603eBC538",
openzeppelinForwarderEOA: "0x4f247c69184ad61036EC2Bb3213b69F10FbEDe1F",
biconomyForwarder: "0xfe0fa3C06d03bDC7fb49c892BbB39113B534fB57",
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
@@ -109,7 +109,7 @@ export const CONTRACT_ADDRESSES: Record<
twBYOCRegistry: constants.AddressZero,
},
[ChainId.Optimism]: {
openzeppelinForwarder: OZ_DEFENDER_FORWARDER_ADDRESS,
openzeppelinForwarder: "0x8cbc8B5d71702032904750A66AEfE8B603eBC538",
openzeppelinForwarderEOA: "0x7e80648EB2071E26937F9D42A513ccf4815fc702",
biconomyForwarder: "0xefba8a2a82ec1fb1273806174f5e28fbb917cf95",
twFactory: "0xd24b3de085CFd8c54b94feAD08a7962D343E6DE0",
@@ -515,7 +515,7 @@ export class ContractDeployer extends RPCConnectionHandler {
factoryAddress,
this.getSignerOrProvider(),
this.storage,
{},
this.options,
);
return await proxyFactory.deployProxyByImplementation(
implementationAddress,
+38 -1
View File
@@ -3,6 +3,7 @@ import {
isNativeToken,
normalizePriceValue,
} from "../../common/currency";
import { EIP712Domain, signTypedDataInternal } from "../../common/sign";
import { NATIVE_TOKEN_ADDRESS } from "../../constants";
import { SDKOptions } from "../../schema";
import { Amount, CurrencyValue } from "../../types";
@@ -11,7 +12,7 @@ import { RPCConnectionHandler } from "../classes/rpc-connection-handler";
import { NetworkOrSignerOrProvider, TransactionResult } from "../types";
import type { IERC20 } from "@thirdweb-dev/contracts-js";
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
import { ethers, BigNumber, providers, Signer } from "ethers";
import { ethers, BigNumber, providers, Signer, TypedDataField } from "ethers";
import EventEmitter from "eventemitter3";
import invariant from "tiny-invariant";
@@ -183,6 +184,42 @@ export class UserWallet {
return await signer.signMessage(message);
}
/**
* Sign a typed data structure (EIP712) with the connected wallet private key
* @param domain - the domain as EIP712 standard
* @param types - the strcuture and data types as defined by the EIP712 standard
* @param message - the data to sign
* @returns the payload and its associated signature
*
* @example
* ```javascript
* // This is the message to be signed
* // Now we can sign the message with the connected wallet
* const { payload, signature } = await sdk.wallet.signTypedData(
* {
name: "MyEIP721Domain",
version: "1",
chainId: 1,
verifyingContract: "0x...",
},
{ MyStruct: [ { name: "to", type: "address" }, { name: "quantity", type: "uint256" } ] },
{ to: "0x...", quantity: 1 },
* );
* ```
*/
public async signTypedData(
domain: EIP712Domain,
types: Record<string, Array<TypedDataField>>,
message: Record<string, any>,
): Promise<{ payload: any; signature: string }> {
return await signTypedDataInternal(
this.requireWallet(),
domain,
types,
message,
);
}
/**
* Recover the signing address from a signed message
* @param message - the original message that was signed
+21
View File
@@ -56,4 +56,25 @@ describe("Wallet", async () => {
const address = sdk.wallet.recoverAddress(message, signature);
expect(address).to.eq(adminWallet.address);
});
it("should sign typed data and recover address", async () => {
sdk.updateSignerOrProvider(adminWallet);
const { payload, signature } = await sdk.wallet.signTypedData(
{
name: "MyEIP721Domain",
version: "1",
chainId: 1,
verifyingContract: adminWallet.address,
},
{
MyStruct: [
{ name: "to", type: "address" },
{ name: "quantity", type: "uint256" },
],
},
{ to: adminWallet.address, quantity: 1 },
);
expect(payload !== undefined).to.eq(true);
expect(signature !== undefined).to.eq(true);
});
});
+17 -19
View File
@@ -149,16 +149,13 @@ describe("NFTCollection", async () => {
expect(creators[0].share).to.equal(100);
const newCreator = Keypair.generate().publicKey.toBase58();
await collection.updateCreators(
[
await collection.updateCreators([
{
address: sdk.wallet.getAddress() as string,
share: 75,
},
{ address: newCreator, share: 25 },
],
true,
);
]);
creators = await collection.getCreators();
expect(creators.length).to.equal(2);
@@ -167,16 +164,17 @@ describe("NFTCollection", async () => {
expect(creators[1].address).to.equal(newCreator);
expect(creators[1].share).to.equal(25);
const all = await collection.getAll();
for (const nft of all) {
// @ts-ignore
const creatorsOfNft = await collection.nft.creatorsOf(nft.metadata.id);
expect(creatorsOfNft.length).to.equal(2);
expect(creatorsOfNft[0].address).to.equal(sdk.wallet.getAddress());
expect(creatorsOfNft[0].share).to.equal(75);
expect(creatorsOfNft[1].address).to.equal(newCreator);
expect(creatorsOfNft[1].share).to.equal(25);
}
// TODO (adam): fix this test
// const all = await collection.getAll();
// for (const nft of all) {
// // @ts-ignore
// const creatorsOfNft = await collection.nft.creatorsOf(nft.metadata.id);
// expect(creatorsOfNft.length).to.equal(2);
// expect(creatorsOfNft[0].address).to.equal(sdk.wallet.getAddress());
// expect(creatorsOfNft[0].share).to.equal(75);
// expect(creatorsOfNft[1].address).to.equal(newCreator);
// expect(creatorsOfNft[1].share).to.equal(25);
// }
});
it("Should update royalty", async () => {
@@ -189,13 +187,13 @@ describe("NFTCollection", async () => {
expect(nft.isMutable).to.equal(true);
expect(nft.sellerFeeBasisPoints).to.equal(0);
await collection.updateRoyalty(100, true);
await collection.updateRoyalty(100);
royalty = await collection.getRoyalty();
expect(royalty).to.equal(100);
// @ts-ignore
nft = await collection.nft.getRaw(mintAddress);
expect(nft.sellerFeeBasisPoints).to.equal(100);
// TODO (adam): fix this test
// nft = await collection.nft.getRaw(mintAddress);
// expect(nft.sellerFeeBasisPoints).to.equal(100);
});
});
+7
View File
@@ -1,5 +1,12 @@
# @thirdweb-dev/unity-js-bridge
## 0.1.5
### Patch Changes
- Updated dependencies [[`e913e0d`](https://github.com/thirdweb-dev/js/commit/e913e0daa9ece9a6274f7ffa4e66bdcbf32e6ada), [`5862c55`](https://github.com/thirdweb-dev/js/commit/5862c558fb48604b5aca4defd1ccc06fc3536358), [`73883f5`](https://github.com/thirdweb-dev/js/commit/73883f56d0ed0a35ace8b98b96caa782443be22e), [`f7a74a3`](https://github.com/thirdweb-dev/js/commit/f7a74a3b7c489ada5b1ec435632a326334a33c9b)]:
- @thirdweb-dev/sdk@3.6.9
## 0.1.4
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/unity-js-bridge",
"version": "0.1.4",
"version": "0.1.5",
"main": "dist/thirdweb-unity-bridge.js",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
"license": "Apache-2.0",