Skip to content

Commit

Permalink
Release 85.0.0 (#1006)
Browse files Browse the repository at this point in the history
* feat: connectwith working with connection

* fix: unit tests

* feat: add connectWith param

* feat: unit test coverage

* fix: coverage

* fix: double connectWith request

* fix: unit tests

* fix: unit tests and cleanup

* feat: release 85.0.0

* feat: changelog
  • Loading branch information
abretonc7s committed Aug 30, 2024
1 parent 3e478c2 commit f96fb19
Show file tree
Hide file tree
Showing 18 changed files with 230 additions and 104 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metamask-sdk-monorepo",
"version": "84.0.0",
"version": "85.0.0",
"private": true,
"repository": {
"type": "git",
Expand Down
27 changes: 16 additions & 11 deletions packages/sdk-communication-layer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.28.2]
### Added
- feat: socket reconnection optimization ([#994](https://github.com/MetaMask/metamask-sdk/pull/994))

## [0.28.1]
### Uncategorized
- feat: full deeplink protocol ([#992](https://github.com/MetaMask/metamask-sdk.git/pull/992))
### Added
- feat: full deeplink protocol ([#992](https://github.com/MetaMask/metamask-sdk/pull/992))

## [0.28.0]
### Added
- feat: experimental deeplink protocoll ([#990](https://github.com/MetaMask/metamask-sdk.git/pull/990))
- feat: revert socket server changes ([#985](https://github.com/MetaMask/metamask-sdk.git/pull/985))
- feat: change the default value for 'dappId' to 'N/A' instead of an empty string ([#972](https://github.com/MetaMask/metamask-sdk.git/pull/972))
- feat: experimental deeplink protocoll ([#990](https://github.com/MetaMask/metamask-sdk/pull/990))
- feat: revert socket server changes ([#985](https://github.com/MetaMask/metamask-sdk/pull/985))
- feat: change the default value for 'dappId' to 'N/A' instead of an empty string ([#972](https://github.com/MetaMask/metamask-sdk/pull/972))

## [0.27.0]
### Added
Expand All @@ -30,14 +34,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.26.0]
### Added
- feat: add script to align version before publishing ([#902](https://github.com/MetaMask/metamask-sdk.git/pull/902))
- feat: update dev rn / expo and empty dappid ([#897](https://github.com/MetaMask/metamask-sdk.git/pull/897))
- feat: prevent empty dappid ([#891](https://github.com/MetaMask/metamask-sdk.git/pull/891))
- chore: improve unit tests coverage ([#888](https://github.com/MetaMask/metamask-sdk.git/pull/888))
- feat: add script to align version before publishing ([#902](https://github.com/MetaMask/metamask-sdk/pull/902))
- feat: update dev rn / expo and empty dappid ([#897](https://github.com/MetaMask/metamask-sdk/pull/897))
- feat: prevent empty dappid ([#891](https://github.com/MetaMask/metamask-sdk/pull/891))
- chore: improve unit tests coverage ([#888](https://github.com/MetaMask/metamask-sdk/pull/888))

## [0.20.5]
### Added
- fix: ref crossfetch ([#871](https://github.com/MetaMask/metamask-sdk.git/pull/871))
- fix: ref crossfetch ([#871](https://github.com/MetaMask/metamask-sdk/pull/871))

## [0.20.4]
### Added
Expand Down Expand Up @@ -245,7 +249,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- [FEAT]: improve logging + update examples ([#99](https://github.com/MetaMask/metamask-sdk/pull/99))

[Unreleased]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]
[0.28.2]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.28.1]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.28.0]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.27.0]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-communication-layer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/sdk-communication-layer",
"version": "0.28.1",
"version": "0.28.2",
"description": "",
"homepage": "https://github.com/MetaMask/metamask-sdk#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-install-modal-web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.26.0]
### Added
- feat: add script to align version before publishing ([#902](https://github.com/MetaMask/metamask-sdk.git/pull/902))
- feat: add script to align version before publishing ([#902](https://github.com/MetaMask/metamask-sdk/pull/902))

## [0.20.4]
### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-react-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.3.1]
### Uncategorized
- chore: update reactNativeSdkDemo with latest sdk-react-native version ([#872](https://github.com/MetaMask/metamask-sdk.git/pull/872))
- chore: update reactNativeSdkDemo with latest sdk-react-native version ([#872](https://github.com/MetaMask/metamask-sdk/pull/872))

## [0.3.0]
### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-react-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.26.0]
### Added
- feat: add script to align version before publishing ([#902](https://github.com/MetaMask/metamask-sdk.git/pull/902))
- feat: add script to align version before publishing ([#902](https://github.com/MetaMask/metamask-sdk/pull/902))

## [0.20.4]
### Added
Expand Down
7 changes: 6 additions & 1 deletion packages/sdk-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.28.0]
### Uncategorized
- feat: revert socket server changes ([#985](https://github.com/MetaMask/metamask-sdk/pull/985))

## [0.27.0]
### Added
- fix: adds extensionOnly default to true to SDK initialization ([#962](https://github.com/MetaMask/metamask-sdk/pull/962))
Expand Down Expand Up @@ -235,7 +239,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [fix] publishing config ([#135](https://github.com/MetaMask/metamask-sdk/pull/135))
- [feat] initial beta released

[Unreleased]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]
[0.28.0]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.27.0]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.26.5]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.26.4]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/sdk-react",
"version": "0.27.0",
"version": "0.28.0",
"description": "A react component and react hooks to connect and use MetaMask",
"homepage": "https://github.com/MetaMask/metamask-sdk",
"bugs": {
Expand Down
11 changes: 8 additions & 3 deletions packages/sdk-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.28.0]
### Uncategorized
- feat: revert socket server changes ([#985](https://github.com/MetaMask/metamask-sdk/pull/985))

## [0.26.0]
### Uncategorized
- feat: add script to align version before publishing ([#902](https://github.com/MetaMask/metamask-sdk.git/pull/902))
- feat: add script to align version before publishing ([#902](https://github.com/MetaMask/metamask-sdk/pull/902))

## [0.20.5]
### Added
- align version with sdk package
- chore: create wagmi demo dapp ([#669](https://github.com/MetaMask/metamask-sdk.git/pull/669))
- chore: create wagmi demo dapp ([#669](https://github.com/MetaMask/metamask-sdk/pull/669))

## [0.4.2]
### Uncategorized
Expand Down Expand Up @@ -83,7 +87,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- feat: optimize rollup builds ([#496](https://github.com/MetaMask/metamask-sdk/pull/496))
- fix: linting changelog issue after updating scripts ([#509](https://github.com/MetaMask/metamask-sdk/pull/509))

[Unreleased]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]
[0.28.0]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.26.0]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.20.5]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.4.2]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/sdk-ui",
"version": "0.26.0",
"version": "0.28.0",
"description": "MetaMask SDK cross-platform ui library",
"module": "dist/esm/index.js",
"types": "dist/esm/dist/src/index.d.ts",
Expand Down
13 changes: 12 additions & 1 deletion packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.28.0]
### Added
- fix: adds a unique id to RPC events for extension ([#996](https://github.com/MetaMask/metamask-sdk/pull/996))
- feat: connectwith working with async key exchange ([#1004](https://github.com/MetaMask/metamask-sdk/pull/1004))
- feat: socket reconnection optimization ([#994](https://github.com/MetaMask/metamask-sdk/pull/994))
- feat: full deeplink protocol ([#992](https://github.com/MetaMask/metamask-sdk/pull/992))
- feat: experimental deeplink protocoll ([#990](https://github.com/MetaMask/metamask-sdk/pull/990))
- feat: revert socket server changes ([#985](https://github.com/MetaMask/metamask-sdk/pull/985))
- feat: change the default value for 'dappId' to 'N/A' instead of an empty string ([#972](https://github.com/MetaMask/metamask-sdk/pull/972))

## [0.27.0]
### Added
- fix: adds extensionOnly default to true to SDK initialization ([#962](https://github.com/MetaMask/metamask-sdk/pull/962))
Expand Down Expand Up @@ -364,7 +374,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- [FEAT] improve logging + update examples ([#99](https://github.com/MetaMask/metamask-sdk/pull/99))

[Unreleased]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]
[0.28.0]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.27.0]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.26.5]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
[0.26.4]: https://github.com/MetaMask/metamask-sdk/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/sdk",
"version": "0.27.0",
"version": "0.28.0",
"description": "",
"homepage": "https://github.com/MetaMask/metamask-sdk#readme",
"bugs": {
Expand Down
13 changes: 10 additions & 3 deletions packages/sdk/src/Platform/MetaMaskInstaller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ describe('MetaMaskInstaller', () => {
});

it('should start installer with connectWith provided', async () => {
const connectWith = { method: 'eth_requestAccounts', params: [] };

const connectWith = {
method: 'eth_requestAccounts',
params: [],
id: '123',
};
await installer.start({ wait: false, connectWith });

expect(installer.state.connectWith).toStrictEqual(connectWith);
Expand All @@ -97,7 +100,11 @@ describe('MetaMaskInstaller', () => {
it('should correctly handle isInstalling in start with wait set to true', async () => {
installer.state.isInstalling = true;

const connectWith = { method: 'eth_requestAccounts', params: [] };
const connectWith = {
method: 'eth_requestAccounts',
params: [],
id: '123',
};

const startPromise = installer.start({ wait: true, connectWith });

Expand Down
14 changes: 2 additions & 12 deletions packages/sdk/src/Platform/MetaMaskInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface InstallerProps {
export interface RPCCall {
method: string;
params: unknown;
id: string;
}

interface MetaMaskInstallerState {
Expand Down Expand Up @@ -78,21 +79,10 @@ export class MetaMaskInstaller {
connectWith,
}: {
wait: boolean;
connectWith?: { method: string; params: unknown };
connectWith?: RPCCall;
}) {
this.state.connectWith = connectWith;
logger(`[MetaMaskInstaller: start()] wait=${wait}`, connectWith);
await startInstaller(this, { wait });

if (wait) {
// wait until the installation is done
while (this.state.isInstalling) {
// FIXME: remove before release
console.warn(
`[MetaMaskInstaller: start()] isInstalling=${this.state.isInstalling}`,
);
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}
}
}
37 changes: 37 additions & 0 deletions packages/sdk/src/provider/initializeMobileProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,17 @@ const initializeMobileProvider = async ({
setInitializing(true);

const isConnectWith = method === RPC_METHODS.METAMASK_CONNECTWITH;
// Only used with connectWith
const rpcInstallId = `${Date.now()}`;
try {
await installer.start({
wait: false,
connectWith: isConnectWith
? {
method,
// We dont need a better id, this is only for current user session.
// future rpc calls will have ids generated via JSON-RPC package.
id: rpcInstallId,
params,
}
: undefined,
Expand Down Expand Up @@ -361,6 +366,38 @@ const initializeMobileProvider = async ({
`[initializeMobileProvider: sendRequest()] selectedAddress: ${selectedAddress} --- SKIP rpc call`,
);
return [selectedAddress];
} else if (method === RPC_METHODS.METAMASK_CONNECTWITH) {
// wait for tracker to be updated

try {
const result = await new Promise((resolve, reject) => {
const tracker = remoteConnection
?.getConnector()
.getRPCMethodTracker();
logger(`TRACKER: method ${rpcInstallId}`, tracker);
if (tracker?.[rpcInstallId].result) {
resolve(tracker?.[rpcInstallId].result);
} else if (tracker?.[rpcInstallId].error) {
reject(tracker?.[rpcInstallId].error);
}

remoteConnection
?.getConnector()
.once(EventType.RPC_UPDATE, (rpcResult) => {
logger(`TRACKER: update method ${rpcInstallId}`, rpcResult);

if (rpcResult.result) {
resolve(rpcResult.result);
} else {
reject(rpcResult.error);
}
});
});
return result;
} catch (error) {
logger(`[initializeMobileProvider: sendRequest()] error:`, error);
throw error;
}
}

// Inform next step that this method triggered installer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('startConnection', () => {
persistChannelConfig: jest.fn(),
},
},
getRPCMethodTracker: jest.fn().mockReturnValue({}),
};

state = {
Expand Down Expand Up @@ -184,6 +185,7 @@ describe('startConnection', () => {
const connectWith = {
method: 'eth_sendTransaction',
params: [{ from: '0x123', to: '0x456', value: '0x789' }],
id: '123',
};

await startConnection(state, options, { connectWith });
Expand All @@ -199,6 +201,7 @@ describe('startConnection', () => {
const connectWith = {
method: 'personal_sign',
params: ['0xabcdef', '0x123456'],
id: '123',
};

await startConnection(state, options, { connectWith });
Expand All @@ -215,6 +218,7 @@ describe('startConnection', () => {
const connectWith = {
method: 'eth_sign',
params: ['0x123456', '0xabcdef'],
id: '123',
};

await startConnection(state, options, { connectWith });
Expand All @@ -230,6 +234,7 @@ describe('startConnection', () => {
const connectWith = {
method: 'eth_sign',
params: ['0x123456', '0xabcdef'],
id: '123',
};

await startConnection(state, options, { connectWith });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,18 @@ export async function startConnection(
}&pubkey=${pubKey}${qrCodeOrigin}&originatorInfo=${base64OriginatorInfo}`;

if (connectWith) {
const rpc = {
id: Date.now(), // We dont need a better id, this is only for current user session.
// future rpc calls will have ids generated via JSON-RPC package.
method: connectWith.method,
params: connectWith.params,
};
const base64Rpc = base64Encode(JSON.stringify(rpc));
const base64Rpc = base64Encode(JSON.stringify(connectWith));
linkParams += `&rpc=${base64Rpc}`;

const tracker = state.connector.getRPCMethodTracker();
// Add rpcMethod to tracker
if (tracker) {
tracker[`${connectWith.id}`] = {
...connectWith,
id: `${connectWith.id}`,
timestamp: Date.now(),
};
}
}
const encodedLinkParams = encodeURI(linkParams);
const qrcodeLink = `${
Expand Down
Loading

0 comments on commit f96fb19

Please sign in to comment.