Skip to content

Commit

Permalink
Merge pull request #264 from steveluscher/polyfill-node-apis-for-webp…
Browse files Browse the repository at this point in the history
…ack-5

Polyfill Node APIs for compatibility with Webpack 5 and Create React App 5
  • Loading branch information
jordaaash authored Jan 20, 2022
2 parents c0db7e6 + 6254476 commit b830c20
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/wallets/ledger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"postbuild": "echo '{\"type\":\"commonjs\"}' | npx json > lib/cjs/package.json && echo '{\"type\":\"module\"} ' | npx json > lib/esm/package.json"
},
"dependencies": {
"buffer": "npm:buffer-browserify@^0.2.5",
"@ledgerhq/hw-transport": "^6.11.2",
"@ledgerhq/hw-transport-webhid": "^6.11.2",
"@solana/wallet-adapter-base": "^0.9.1",
Expand Down
2 changes: 2 additions & 0 deletions packages/wallets/ledger/src/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './polyfills/index';

import type Transport from '@ledgerhq/hw-transport';
import {
Adapter,
Expand Down
7 changes: 7 additions & 0 deletions packages/wallets/ledger/src/polyfills/Buffer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Buffer } from 'buffer';

if (typeof window !== 'undefined' && window.Buffer === undefined) {
(window as any).Buffer = Buffer;
}

export {};
3 changes: 3 additions & 0 deletions packages/wallets/ledger/src/polyfills/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

import './Buffer';
2 changes: 2 additions & 0 deletions packages/wallets/ledger/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './polyfills/index';

import Transport, { StatusCodes, TransportStatusError } from '@ledgerhq/hw-transport';
import { PublicKey, Transaction } from '@solana/web3.js';

Expand Down
2 changes: 2 additions & 0 deletions packages/wallets/torus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
"postbuild": "echo '{\"type\":\"commonjs\"}' | npx json > lib/cjs/package.json && echo '{\"type\":\"module\"} ' | npx json > lib/esm/package.json"
},
"dependencies": {
"assert": "npm:assert@^2.0.0",
"@solana/wallet-adapter-base": "^0.9.1",
"@solana/web3.js": "^1.20.0",
"stream": "npm:stream-browserify@^3.0.0",
"@toruslabs/solana-embed": "^0.0.9",
"@types/keccak": "^3.0.1",
"@types/readable-stream": "^2.3.11"
Expand Down
24 changes: 22 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5348,9 +5348,9 @@ [email protected], assert-plus@^1.0.0:
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525"
integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=

[email protected], assert@^2.0.0:
[email protected], assert@^2.0.0, "assert@npm:assert@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32"
resolved "https://registry.npmjs.org/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32"
integrity sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A==
dependencies:
es6-object-assign "^1.1.0"
Expand Down Expand Up @@ -5672,6 +5672,11 @@ base-x@^3.0.2, base-x@^3.0.6, base-x@^3.0.8:
dependencies:
safe-buffer "^5.0.1"

[email protected]:
version "0.0.8"
resolved "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978"
integrity sha1-EQHpVE9KdrG8OybUUsqW16NeeXg=

base64-js@^1.0.2, base64-js@^1.2.0, base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
Expand Down Expand Up @@ -6040,6 +6045,13 @@ buffer@^6.0.3, buffer@~6.0.3:
base64-js "^1.3.1"
ieee754 "^1.2.1"

"buffer@npm:buffer-browserify@^0.2.5":
version "0.2.5"
resolved "https://registry.npmjs.org/buffer-browserify/-/buffer-browserify-0.2.5.tgz#29c739d6a4e247b539abc0ada073612002163a21"
integrity sha1-Kcc51qTiR7U5q8CtoHNhIAIWOiE=
dependencies:
base64-js "0.0.8"

bufferutil@^4.0.1:
version "4.0.6"
resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.6.tgz#ebd6c67c7922a0e902f053e5d8be5ec850e48433"
Expand Down Expand Up @@ -16318,6 +16330,14 @@ stream-parser@^0.3.1:
dependencies:
debug "2"

"stream@npm:stream-browserify@^3.0.0":
version "3.0.0"
resolved "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz#22b0a2850cdf6503e73085da1fc7b7d0c2122f2f"
integrity sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==
dependencies:
inherits "~2.0.4"
readable-stream "^3.5.0"

strict-uri-encode@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
Expand Down

0 comments on commit b830c20

Please sign in to comment.