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

add web3modal extension #742

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4df5a5a
add web3modal extension
hcote Apr 22, 2024
0b7d9c7
remove unused vars
hcote Apr 22, 2024
a5864bb
rename
hcote Apr 22, 2024
55cc255
move override methods to thirdpartywallet module
hcote Apr 23, 2024
a746b06
remove provider dependency
hcote Apr 23, 2024
ffbb08d
typing updates
hcote Apr 24, 2024
a92e507
fix logout on disconnect
hcote Apr 24, 2024
a29c027
add returns to fns routing to tpw methods
hcote Apr 24, 2024
c3b302e
Merge branch 'master' into hcote-web3modal
hcote Apr 24, 2024
26604e3
move all logic to thirdpartywallet module
hcote Apr 25, 2024
42a4280
dont route nftCheckout to 3pw
hcote Apr 25, 2024
5a56d1a
update iframe.allow for google login
hcote Apr 30, 2024
3732179
fix capitalization
hcote May 4, 2024
56bb93c
add connectWIthUI options param
hcote May 7, 2024
f262429
make param optional
hcote May 12, 2024
b9b9caa
add event 1193 event listeners after connecting
hcote May 13, 2024
56fde71
update isConnected initialization
hcote May 14, 2024
3390b6f
remove old tests
hcote May 15, 2024
ad6d291
update tests
hcote May 18, 2024
dac3493
fix deepsource lint errors
hcote May 19, 2024
7953979
Merge branch 'master' into hcote-web3modal
hcote May 19, 2024
3a83159
update ls key names
hcote May 20, 2024
d328947
temp: remove reference to ThirdPartyWallets
hcote May 21, 2024
b44497f
update import
hcote May 21, 2024
53124ba
pluralize thirdpartywallets & update to web3modal canary version for …
hcote May 29, 2024
afa46ff
fix tests
hcote May 29, 2024
0386f43
implement nft.checkout with 3rd-party wallets (#744)
octave08 May 31, 2024
e8f9583
nft checkout update
hcote May 31, 2024
d862d23
add intermediary events for nft.checkout
hcote Jun 6, 2024
baa4f36
Merge branch 'master' into hcote-web3modal
hcote Jun 6, 2024
7ebccbf
Merge branch 'master' into hcote-web3modal
hcote Jun 7, 2024
218e104
yarn.lock
hcote Jun 7, 2024
c714eea
update web3modal package
hcote Jun 12, 2024
c05cd91
Merge branch 'master' into hcote-web3modal
hcote Jun 12, 2024
884053f
yarn.lock
hcote Jun 12, 2024
39d6e46
update web3modal package
hcote Jun 14, 2024
ff13a5f
yarn.lock
hcote Jun 14, 2024
17937db
update web3modal sdk
hcote Jun 20, 2024
3fe30b8
Merge branch 'master' into hcote-web3modal
hcote Jun 20, 2024
fb7b0c8
remove unsubscribeFromModalEvents
hcote Jun 21, 2024
911b23e
remove comments
hcote Jun 21, 2024
adddb32
add web3modal polyfill
hcote Jun 22, 2024
f0a0b3a
pass configOptions directly
hcote Jul 2, 2024
bca2cfc
Merge branch 'master' into hcote-web3modal
hcote Jul 2, 2024
9499a53
remove polyfills
hcote Jul 2, 2024
3194efc
update eslint config
hcote Jul 2, 2024
95261f5
update jest coverage
hcote Jul 2, 2024
2b79c30
Merge branch 'master' into hcote-web3modal
hcote Jul 13, 2024
e3ecd35
yarn
hcote Jul 13, 2024
561e4f0
yarn.lock
hcote Jul 13, 2024
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
Prev Previous commit
Next Next commit
nft checkout update
  • Loading branch information
hcote committed May 31, 2024
commit e8f9583a9992460e269e924107e7b37ec51fbf80
12 changes: 7 additions & 5 deletions packages/@magic-ext/web3modal-ethers5/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ export class Web3ModalExtension extends Extension.Internal<'web3modal'> {
private connectToWeb3modal(payloadId: string) {
const { modal } = this;

const promiEvent = this.utils.createPromiEvent<string[]>(() => {
// If user is already connected, emit event and return
if (this.modal.getIsConnected()) {
this.handleUserConnected(payloadId);
return;
const promiEvent = this.utils.createPromiEvent<string[]>(async () => {
try {
if (modal.getIsConnected()) {
await modal.disconnect();
}
} catch (error) {
console.error(error);
}

// Listen for wallet connected event
Expand Down
18 changes: 2 additions & 16 deletions packages/@magic-sdk/provider/src/modules/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,35 @@ export class NFTModule extends BaseModule {

/* Start an NFT Checkout flow with Paypal */
public checkout(options: NFTCheckoutRequest) {
// const promiEvent = createPromiEvent<any, NFTCheckoutEvents>((resolve) => {
// How to tell if user is logged in with a third-party wallet

// TODO: remove this line after testing
// const isThirdPartyWalletConnected = true;
const isThirdPartyWalletConnected = this.sdk.thirdPartyWallets.isConnected;
console.log({ isThirdPartyWalletConnected });

const requestPayload = createJsonRpcRequestPayload(MagicPayloadMethod.NFTCheckout, [
{
...options,
// Indicating to iframe if third party wallet
walletProvider: isThirdPartyWalletConnected ? 'web3modal' : 'magic',
},
]);
const req = this.request<NFTCheckoutResponse>(requestPayload);

// Add intermediary event listener if user is purchasing with a third-party wallet
if (isThirdPartyWalletConnected) {
// Listen for `nft-checkout-initiated` event from iframe
req.on(NftCheckoutEventOnReceived.Initiated as any, async (rawTransaction) => {
try {
console.log('RECEIVED', rawTransaction);
// prompt third party wallet with transaction details
const hash = await this.request({
method: 'eth_sendTransaction',
params: [rawTransaction],
});

console.log({ hash });
// emit `nft-checkout-success` intermediary event to iframe if developer sent tx
console.log('hash from sdk', hash);
this.createIntermediaryEvent(NftCheckoutEventEmit.Success, requestPayload.id as string)(hash);
} catch (error) {
console.log(error);
// if rejected, emit `nft-checkout-failure` intermediary event to iframe
console.error('error from sdk', error);
this.createIntermediaryEvent(NftCheckoutEventEmit.Failure, requestPayload.id as string)();
}
});
}
return req;
// resolve(req);
// });
// return promiEvent;
}

/* Start an NFT Transfer flow */
Expand Down
Loading