@dappql/react 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Mutation.d.ts.map +1 -1
- package/dist/Mutation.js +14 -2
- package/package.json +1 -1
package/dist/Mutation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mutation.d.ts","sourceRoot":"","sources":["../src/Mutation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,KAAK,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxD,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAA;AAE9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAEtD,iBAAS,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,SAAS,SAAS,GAAG,EAAE,EAChE,MAAM,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,EAC/B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,MAAM,EAAE,YAAY,GAAG,SAAS,aAGd,IAAI,8KAYvB;AAED,iBAAS,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,SAAS,SAAS,GAAG,EAAE,EAChE,MAAM,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,EAC/B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,MAAM,EAAE,YAAY,GAAG,SAAS,aAGd,IAAI,qBAYvB;AAED,iBAAS,uBAAuB,CAAC,IAAI,EAAE,KAAK,MAAM,EAAE,GAAG,SAAS;;;;;;;;;;;;;;;;;;;GAE/D;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GACvB;IACE,8CAA8C;IAC9C,eAAe,CAA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AAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAA;IAChD,IAAI,EAAE,OAAO,GAAG,SAAS,CAAA;IACzB,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAA;IACpC,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,sBAAsB,GAAG,IAAI,CAAA;IAC5C,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA;IACxD,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAC7B,QAAQ,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IACjD,QAAQ,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;CAClD,CA2IA;AAED;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,SAAS,SAAS,GAAG,EAAE,IAAI,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA"}
|
package/dist/Mutation.js
CHANGED
|
@@ -49,7 +49,7 @@ function useMutationConfirmation(hash) {
|
|
|
49
49
|
*/
|
|
50
50
|
export function useMutation(config, optionsOrTransactionName) {
|
|
51
51
|
const { addressResolver, onMutationUpdate, simulateMutations } = useDappQL();
|
|
52
|
-
const { chain, address: account } = useAccount();
|
|
52
|
+
const { chain, address: account, connector } = useAccount();
|
|
53
53
|
const tx = useWriteContract();
|
|
54
54
|
const client = usePublicClient();
|
|
55
55
|
const address = useMemo(() => optionsOrTransactionName && typeof optionsOrTransactionName !== 'string' && optionsOrTransactionName.address
|
|
@@ -70,6 +70,16 @@ export function useMutation(config, optionsOrTransactionName) {
|
|
|
70
70
|
const send = useCallback((...args) => {
|
|
71
71
|
const now = Date.now();
|
|
72
72
|
const id = mutationInfo.address + mutationInfo.functionName + now.toString();
|
|
73
|
+
// Captured when the caller asks to send, and used for the write below.
|
|
74
|
+
//
|
|
75
|
+
// `writeContract` resolves the active connection inside its own mutation
|
|
76
|
+
// function, which runs after a yield — and after `simulate` below, which
|
|
77
|
+
// is awaited. A wallet event landing in either gap would otherwise sign
|
|
78
|
+
// with whoever is connected then, against arguments built and simulated
|
|
79
|
+
// for whoever was connected when the caller decided to send. Binding both
|
|
80
|
+
// makes wagmi fail that write instead of retargeting it.
|
|
81
|
+
const boundAccount = account;
|
|
82
|
+
const boundConnector = connector;
|
|
73
83
|
if (!account || !chain?.id) {
|
|
74
84
|
const error = !account ? 'No account connected' : 'Invalid chain';
|
|
75
85
|
onMutationUpdate?.({
|
|
@@ -88,6 +98,8 @@ export function useMutation(config, optionsOrTransactionName) {
|
|
|
88
98
|
address,
|
|
89
99
|
chainId: chain?.id,
|
|
90
100
|
args,
|
|
101
|
+
account: boundAccount,
|
|
102
|
+
connector: boundConnector,
|
|
91
103
|
}, {
|
|
92
104
|
onSettled(data, error) {
|
|
93
105
|
const status = error ? 'error' : 'signed';
|
|
@@ -124,7 +136,7 @@ export function useMutation(config, optionsOrTransactionName) {
|
|
|
124
136
|
else {
|
|
125
137
|
sendTx();
|
|
126
138
|
}
|
|
127
|
-
}, [address, tx, config, account, chain?.id, options?.simulate, simulateMutations, client, simulate]);
|
|
139
|
+
}, [address, tx, config, account, connector, chain?.id, options?.simulate, simulateMutations, client, simulate]);
|
|
128
140
|
const confirmation = useMutationConfirmation(tx.data);
|
|
129
141
|
return useMemo(() => ({
|
|
130
142
|
status: tx.status,
|