We have been working on Document Signing App which sends an email when a user uploads a document and sends it to sign to another 3-4 users.
The user gets the email and tries to sign the document which does a blockchain transaction whose status is always failed.
We have been trying to debug this but unfortunately we haven’t any details lately, We have tried various codes but no changes have changed the status of transaction.
Our System Details :
Provider : Alchemy
Network : Goerli / Localhost ( Hardhat node )
Local Dev : Hardhat
We also tried to use hardhat console.sol but we could not get any logs in the contract when using Hardhat node, No logs were printed using npx hardhat test.
We have been facing this problem since almost a week now and the transaction is stil failing.
Snapshot of Local Error :
ProviderError: Error: Transaction reverted without a reason string
at HttpProvider.request (node_modules/hardhat/src/internal/core/providers/http.ts:78:19)
at GanacheGasMultiplierProvider.request (node_modules/hardhat/src/internal/core/providers/gas-providers.ts:312:34)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Smart Contract that is failing in actual transaction :
function sign(bytes32 hash, bytes32 signatureHash, address signer) public {
console.log("Entered Sign Function");
require(checkDoc(hash),"check doc failed");
require(documents[hash].signers[signer] == 1, "signer failed");
documents[hash].remainingSignatures--;
documents[hash].signers[signer] = block.timestamp;
emit Signature(hash, signatureHash, signer, 'Signature');
if (documents[hash].remainingSignatures == 0){
documents[hash].status = currentState.signed;
emit Signed(hash, 'Signed');
}
Require is not the issue because when we comment out require statements the transaction is still failing.
Code for Test case that is failing :
it("Signing contract", async function () {
const DocumentSigning = await ethers.getContractFactory("DocumentSigning");
const document_signing = await DocumentSigning.deploy();
const transactionOptions = {
gasLimit: 2500000
}
await document_signing.sign("0x46742b637a5c1d01460033c3bd178d1fafe78e0dffa5d2d1841dcccaf70d30a9", "0xef02795fa1b0c97abe843fb461b4625a6a24662bff227862d7d292c9fc69c1ab", "0x07906aae1204f6f3b81673562db7776af9acf83c", transactionOptions);
});
});
The values for test cases have been hardcoded for now to test the actual transaction flow.
Can some help on this as soon as possible?
Adding link to a sample transaction that failed :
https://goerli.etherscan.io/tx/0x4c1665f793541846457a27467236d5fccca63588be3064c78682f666393adc74
Related
I am currently developing a dapp and I am integrating walletconnect.
I use this code for connecting:
const chainId = ContractService.getPreferredChainId();
const rpc = ContractService.getRpcAddress();
provider = new WalletConnectProvider({
infuraId: undefined,
rpc: {
[chainId]: rpc,
},
});
await provider.enable();
chainId is dynamically chosen based on if the app is in development mode or not. while in development it runs on chain id 97.
RPC is the same story, it just gets the binance smart chain RPC JSON provider.
Connecting works well, but I get the following error:
Any idea on how I can fix this without making an infura account? Or is that required..
I found out what the problem was.
make sure to add a chainId to the object like this:
new WalletConnectProvider({
infuraId: undefined,
rpc: {
1: "https://RPC_URL",
},
chainId: 1
});
Then it should work without issues, you can even omit the infuraId field
Trying to embed kin.js in an Ionic App, I can see that the key creation using Keypairs and network initialization is ok
const keys = Keypair.random();
const network = KinNetwork.Production;
However when I try to create the wallet
createWallet(network, keys)
.then(res => {
console.log(res);
}, (err) => {
console.log(err)
});
It keeps retrying but at the end it replies with Error: failed to load account:
I can see the API call is made
https://horizon-kin-ecosystem.kininfrastructure.com/accounts/GANWXV7IHG6YGWVIXJNB56OCBIYI7LYKD34CH556YCDOP5LRC2WDJLTC?c=0.32263221858689695
but the response includes this object
{
“type”: “https://stellar.org/horizon-errors/not_found",
“title”: “Resource Missing”,
“status”: 404,
“detail”: “The resource at the url requested was not found. This is usually occurs for one of two reasons: The url requested is not valid, or no data in our database could be found with the parameters provided.”
}
Any missing parameters I should supply beyond the network and keys
I'm trying to run MFP8's push sample app of GitHub. But MFPPush.registerDevice method failed and error message "Failed to register device:" was shown.
function registerDevice() {
WLAuthorizationManager.obtainAccessToken("push.mobileclient").then(
MFPPush.registerDevice(
null,
function(successResponse) {
navigator.notification.alert("Successfully registered");
enableButtons();
},
function(failureResponse) {
navigator.notification.alert("Failed to register");
console.log("Failed to register device:" +
JSON.stringify(failureResponse));
}
)
);
}
I read the MFP8 document and found the note below.
Note: Authenticated notifications are currently not supported in Cordova applications due to a defect. However a workaround is provided: each MFPPush API call can be wrapped by WLAuthorizationManager.obtainAccessToken("push.mobileclient").then( ... );. The provided sample application uses this workround.
The sample code is wrapped by WLAuthorizationManager.obtainAccessToken indeed. But I think MFPPush.registerDevice may be called before 'obtainAccessToken' completes because return value of MFPPush.registerDevice's method is specified as Promise.then() parameter instead of function that call MFPPush.registerDevice.
So I think the sample should be written as bellow,
function registerDevice() {
WLAuthorizationManager.obtainAccessToken("push.mobileclient").then(
function() {
MFPPush.registerDevice(
null,
function(successResponse) {
navigator.notification.alert("Successfully registered");
enableButtons();
},
function(failureResponse) {
navigator.notification.alert("Failed to register");
console.log("Failed to register device:" +
JSON.stringify(failureResponse));
}
)
);
}
}
Could anyone give me some advice about that?
There is additional information. In device log these messages were logged.
Of course, I registered UserLogin security check to MobileFirst Server and UserLogin challengeHandler is created in UserLoginChallengeHandler.js
(I have not changed except bundleId)
2018-02-10 19:42:47.271015+0900 PushNotificationsCordova[1273:1500711] Failed to register device:"Error Domain=com.ibm.mfp.push Code=5 \"Error authenticating client. Error is 'Challenge handler does not exist. There is no registered challenge handler with key UserLogin'.\" UserInfo={networkMetadata={\n \"$bytesSent\" = 120;\n \"$category\" = network;\n \"$outboundTimestamp\" = 1518259366869;\n \"$path\" = \"http://192.168.0.105:9080/mfp/api/preauth/v1/preauthorize\";\n \"$requestMethod\" = POST;\n \"$trackingid\" = \"F8FD4A96-B046-4DAD-87F6-7441E8426C2E\";\n}, NSLocalizedDescription=Error authenticating client. Error is 'Challenge handler does not exist. There is no registered challenge handler with key UserLogin'.}"
I'm using GCP and I want to use Cloud Pub/Sub. I got this error below when I tried Node.js sample. Does anyone knows how to fix it?
/private/tmp/pubsub/pubsubsample.js:26
subscription.on('error', onError);
^
TypeError: Cannot read property 'on' of null
at /private/tmp/pubsub/pubsubsample.js:26:15
at /private/tmp/pubsub/node_modules/gcloud/lib/pubsub/index.js:474:7
at Object.handleResp (/private/tmp/pubsub/node_modules/gcloud/lib/common/util.js:113:3)
at /private/tmp/pubsub/node_modules/gcloud/lib/common/util.js:422:12
at Request.onResponse [as _callback] (/private/tmp/pubsub/node_modules/gcloud/node_modules/retry-request/index.js:106:7)
at Request.self.callback (/private/tmp/pubsub/node_modules/gcloud/node_modules/request/request.js:198:22)
at emitTwo (events.js:87:13)
at Request.emit (events.js:172:7)
at Request.<anonymous> (/private/tmp/pubsub/node_modules/gcloud/node_modules/request/request.js:1035:10)
at emitOne (events.js:82:20)
https://github.com/GoogleCloudPlatform/gcloud-node
var gcloud = require('gcloud');
// Authenticating on a per-API-basis. You don't need to do this if you
// auth on a global basis (see Authentication section above).
var pubsub = gcloud.pubsub({
projectId: 'xxxxx',
keyFilename: 'xxx.json'
});
// Reference a topic that has been previously created.
var topic = pubsub.topic('info');
// Publish a message to the topic.
topic.publish({
data: 'New message!'
}, function(err) {});
// Subscribe to the topic.
topic.subscribe('new-subscription', function(err, subscription) {
// Register listeners to start pulling for messages.
function onError(err) {}
function onMessage(message) {}
subscription.on('error', onError);
subscription.on('message', onMessage);
// Remove listeners to stop pulling for messages.
subscription.removeListener('message', onMessage);
subscription.removeListener('error', onError);
});
... I'm using now PubSub but I'm thinking whether I can do same thing by using Google Cloud PubSub.
This post may be relevant. Node.js on Google Cloud Platform Pub/Sub tutorial worker is failing with "TypeError: Cannot call method 'on' of null"
Update 1
I changed to this code but same error was showed.
(error)
subscription.on('error', onError);
^
TypeError: Cannot read property 'on' of null
(code)
// Subscribe to the topic
topic.subscribe('new-subscription', function(err, subscription) {
if( err ) {
// something went wrong, react!
return;
}
// Register listeners to start pulling for messages.
function onError(err) {}
function onMessage(message) {}
subscription.on('error', onError);
subscription.on('message', onMessage);
// Remove listeners to stop pulling for messages.
subscription.removeListener('message', onMessage);
subscription.removeListener('error', onError);
});
Update 2
My expectation is this below.
execute "node pubsub.js"
I can see the sample message 'New message!'
When invoking topic.subscribe(), the method essentially invokes the pubsub.subscribe() method with a specific Topic instance as its context. This can be seen from the source code under Topic.prototype.subscribe.
Based on the PubSub index.js source code, PubSub.prototype.subscribe() issues a HTTP request to create a new subscription respecting the projects.subscriptions.create API format. If the response returns a 409 ALREADY_EXISTS error and you have not set the options.reuseExisting to true, the callback you provided will be invoked with the error and null as a subscription. According to the PubSub Nodejs documentation for topic.subscribe under options.reuseExisting, the default value if not specified is false and
If false, attempting to create a subscription that already exists will
fail.
To use this design more effectively, I would suggest the following:
var pubsub = require('gcloud').pubsub({
"projectId" : "project-id",
"keyFilename" : "key-file.json"
});
// This topic should already have been created
var topic = pubsub.topic("interesting-topic");
// The message that will be published
var message = {"data": "Welcome to this interesting thread"};
// Callback to throw an exception if publish was unsuccessful
// Will log published message IDs if successful
function publishedHandler(err, messageIds, responseBody) {
if (err) {
// Could not publish message(s)
throw err;
}
console.log(messagesIds);
}
// Callback to throw an exception if a subscription could not be found or created
// Will attach event listeners if successfully gets a subscription
function subscriptionHandler(err, subscription, responseBody) {
if (err) {
// Could not get or create a new subscription
throw err;
}
subscription.on("error", errorHandler);
subscription.on("message", messageHandler);
}
// Publish a message to the topic
topic.publish(message, publishedHandler);
// Create or get 'sub' and subcribe it to 'interesting-topic'
topic.subscribe("sub", {"reuseExisting": true}, subscriptionHandler);
Issue 696 may not refer exactly to this issue but does discuss some of the semantic choices made in designing the Node.js library for Cloud PubSub. It's not entirely clear if methods like topic.publish or topic.subscribe check for existence of a topic, existence of a subscription, create a new subscription or get an existing subscription. I would simply warn to add robust error handling.
Currently you do not check for errors, when subscribing, but just errors while being subscribed. To change that, you can use something like this:
// Subscribe to the topic.
topic.subscribe('new-subscription', function(err, subscription) {
// first check for errors
if( err ) {
// something went wrong, react!
return;
}
// rest of your code
});
Hello it's my first time doing a sign in process in a mobile app with Titanium and I wonder what information should I save and the best practice to do it?
My server is configured in this way:
The server requires I send a user and password and if the information match it will provide a token session.
This is the code I use for signing in:
function signIn(e) {
//function to use HTTP to connect to a web server and transfer the data.
var sendit = Ti.Network.createHTTPClient({
onerror : function(e) {
Ti.API.debug(e.error);
alert('There was an error during the connection');
},
timeout : 100000,
});
//Here you have to change it for your local ip
sendit.open('POST', 'http://myserver');
var params = {
user : $.txtUsuario.value,
password : $.txtPassword.value
};
sendit.send(params);
//Function to be called upon a successful response
sendit.onload = function() {
var json = this.responseText;
var response = JSON.parse(json);
if (response.success == "true")
{
var landing = Alloy.createController("menu").getView();
$.index.close();
landing.open();
}
else
{
alert(response);
}
};
};
the code above is working, however I do not know how to manage the sign out. I would like my application works like the most apps do, e.g:
You sign in once and after that if you do not close the app you are able to continues using it and even making a request.
Thank you for any explanation.
It depends on your app requirements. for exemple if you will use the token in your app later you can save it as an AppProperty :
Ti.App.Properties.setString('token',yourTokenGoHere);
and in the app starting you can get it back :
var myToken = Ti.App.Properties.getString('token');
and then you can make a test for example if the token is still valid or not :
if(myToken === 'invalidtoken')
youSholdLogin();
else
youCanGoFurther();
and when the user disconnect rest the token to be invalid :
Ti.App.Properties.setString('token', 'invalidtoken');