Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize: SDK bundle size by ~100kb #478

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pretty-cats-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@safe-global/safe-apps-sdk': major
---

Optimized SDK bundle size by ~100kb
2 changes: 1 addition & 1 deletion packages/safe-apps-sdk/dist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"license": "MIT",
"dependencies": {
"@safe-global/safe-gateway-typescript-sdk": "^3.5.3",
"ethers": "^5.7.2"
"viem": "0.3.21"
},
"devDependencies": {
"rimraf": "^3.0.2"
Expand Down
90 changes: 78 additions & 12 deletions packages/safe-apps-sdk/dist/src/safe/index.js

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

2 changes: 1 addition & 1 deletion packages/safe-apps-sdk/dist/src/safe/index.js.map

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

5 changes: 1 addition & 4 deletions packages/safe-apps-sdk/dist/src/safe/signatures.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { ethers } from 'ethers';
declare const MAGIC_VALUE = "0x1626ba7e";
declare const MAGIC_VALUE_BYTES = "0x20c13b0b";
declare const EIP_1271_INTERFACE: ethers.utils.Interface;
declare const EIP_1271_BYTES_INTERFACE: ethers.utils.Interface;
export { EIP_1271_INTERFACE, EIP_1271_BYTES_INTERFACE, MAGIC_VALUE, MAGIC_VALUE_BYTES };
export { MAGIC_VALUE, MAGIC_VALUE_BYTES };
11 changes: 1 addition & 10 deletions packages/safe-apps-sdk/dist/src/safe/signatures.js

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

2 changes: 1 addition & 1 deletion packages/safe-apps-sdk/dist/src/safe/signatures.js.map

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

1 change: 1 addition & 0 deletions packages/safe-apps-sdk/dist/src/setupTests.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
5 changes: 5 additions & 0 deletions packages/safe-apps-sdk/dist/src/setupTests.js

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

1 change: 1 addition & 0 deletions packages/safe-apps-sdk/dist/src/setupTests.js.map

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

8 changes: 5 additions & 3 deletions packages/safe-apps-sdk/dist/src/types/sdk.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChainInfo as _ChainInfo } from '@safe-global/safe-gateway-typescript-sdk';
import { BigNumberish, BytesLike } from 'ethers';
export type ChainInfo = Pick<_ChainInfo, 'chainName' | 'chainId' | 'shortName' | 'nativeCurrency' | 'blockExplorerUriTemplate'>;
export { NativeCurrency } from '@safe-global/safe-gateway-typescript-sdk';
export type BaseTransaction = {
Expand All @@ -26,9 +25,11 @@ export type SignMessageParams = {
export interface TypedDataDomain {
name?: string;
version?: string;
chainId?: BigNumberish;
chainId?: string | number | bigint | {
toNumber: () => number;
};
verifyingContract?: string;
salt?: BytesLike;
salt?: string;
}
export interface TypedDataTypes {
name: string;
Expand All @@ -41,6 +42,7 @@ export type EIP712TypedData = {
domain: TypedDataDomain;
types: TypedMessageTypes;
message: Record<string, any>;
primaryType?: string;
};
export type SignTypedMessageParams = {
typedData: EIP712TypedData;
Expand Down
19 changes: 19 additions & 0 deletions packages/safe-apps-sdk/jest-environment-jsdom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// https://github.com/paralleldrive/cuid2/issues/44#issuecomment-1531731695
const { TextEncoder, TextDecoder } = require('util');
const { default: $JSDOMEnvironment, TestEnvironment } = require('jest-environment-jsdom');

Object.defineProperty(exports, '__esModule', {
value: true,
});

class JSDOMEnvironment extends $JSDOMEnvironment {
constructor(...args) {
const { global } = super(...args);
global.Uint8Array = Uint8Array;
if (!global.TextEncoder) global.TextEncoder = TextEncoder;
if (!global.TextDecoder) global.TextDecoder = TextDecoder;
}
}

exports.default = JSDOMEnvironment;
exports.TestEnvironment = TestEnvironment === $JSDOMEnvironment ? JSDOMEnvironment : TestEnvironment;
2 changes: 1 addition & 1 deletion packages/safe-apps-sdk/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module.exports = {
moduleDirectories: ['node_modules', 'src'],
roots: ['src'],
verbose: true,
testEnvironment: 'jsdom',
testEnvironment: './jest-environment-jsdom.js',
};
2 changes: 1 addition & 1 deletion packages/safe-apps-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"license": "MIT",
"dependencies": {
"@safe-global/safe-gateway-typescript-sdk": "^3.5.3",
"ethers": "^5.7.2"
"viem": "1.0.0"
VladimirMikulic marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"rimraf": "^3.0.2"
Expand Down
Loading